I was watching this mailing list and found this
posting useful. Even my environment is same except
that i'm using MS Access on windows 2000 machine. I
followed what Mr. Luke has done and it works fine for
me too. Earlier i was using JDBC connection as
follows:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn =
DriverManager.getConnection("jdbc:odbc:driver={Microsoft
Access Driver
(*.mdb)};DBQ=C:/tomcat/webapps/db1/db1.mdb");
Now i included following in srever.xml under
GlobalNamingResources.
<Resource
name="db1"
type="javax.sql.DataSource"
password=""
driverClassName="sun.jdbc.odbc.JdbcOdbcDriver"
maxIdle="2"
maxWait="5000"
username=""
url="jdbc:odbc:db1"
maxActive="4"/>
and changed the code on my JSP follows:
Connection conn = null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc:odbc:db1");
And it works fine. I'm able to work on database.
What is the drawback in doing like this? Is it fine to
do this way? If not, what changes i need to do to the
existing set-up? Pls inform.
Thanks.
--- Parsons Technical Services
<[EMAIL PROTECTED]> wrote:
> Luke,
>
> I should have read closer. What you have done is to
> create a connection
> without pooling. The language in the servlet does
> not call the resource that
> you created in the server.xml . If you don't need
> pooling you can remove the
> Global resource. If you want pooling, you need to
> change the servlet.
>
> As for why all three work, you need to look at your
> setup.
> Is the database protected with a password?
> Did you declare a password in the DSN?
>
> Glad you got things working, but I wanted you to
> know that they were not
> working as you thought.
>
> Doug
>
>
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Saturday, March 26, 2005 4:27 AM
> Subject: Re: tomcat 5.5.7 / windowsXP / access
> database
>
>
> > Hi,
> >
> > I've solved the problem.
> > I needed to declare a 'system-wide' datasource on
> the windowsXP box.
> > In adminstrative tools, firstup I declared a user
> DSN, that has to be
> > a System DSN,
> > then it worked.
> >
> > NOTE: the DriverManager.getConnection() method has
> a few different
> > constructors. Once you have the System wide DSN,
> any of the following
> > constructors work:
> > DriverManager.getConnection("jdbc:odbc:db");
> > DriverManager.getConnection("jdbc:odbc:db","","");
> >
>
DriverManager.getConnection("jdbc:odbc:db","user","pass");
> >
> > these all worked regardless of the settings for
> 'username' and
> > 'password' in server.xml, even deleting those to
> settings from
> > server.xml didn't affect access to the access
> database.
> > THis was once again confirmed by rebooting the
> windows box and
> > (obviously) starting all services again.
> >
> > Have a great Easter!
> > Luke
> >
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > Hi,
> >
> > I've recently started to experiment with tomcat
> 5.5.7 on windows XP,
> > trying to access an Access (.mdb) database.
> > I've set up a datasource in windows administration
> tools and used the
> > the tomcat administration (which had to be
> installed separately) to
> > configure a datasource in tomcat.
> >
> > this gave me the following in 'server.xml' under
> GlobalNamingResources:
> > _______________
> > /
> > <Resource
> > name="movies"
> > type="javax.sql.DataSource"
> > password=""
> > driverClassName="sun.jdbc.odbc.JdbcOdbcDriver"
> > maxIdle="2"
> > maxWait="5000"
> > username=""
> > url="jdbc:odbc:movies"
> > maxActive="4"/>
> > \_______________
> >
> > I then got a servlet going with the following:
> > _______________
> > /
> > Connection con = null;
> > try {
> > // Load the Driver class file
> >
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> > out.println("Getting Connection!");
> > // Make a connection to the ODBC datasource
> Movie Catalog
> > // In this example we are opening a
> connection to the
> > // database with every request.
> > con =
>
DriverManager.getConnection("jdbc:odbc:movies","","");
> > if ( con == null ) {
> > out.println("no Connection!");
> > }
> > else {
> > out.println("we have a connection");
> > }
> > \_______________
> >
> > restarted tomcat and tried but get the following
> message after an
> > SqlException is thrown.
> > _______________
> > /
> > SQLException -- [Microsoft][ODBC Driver Manager]
> Data source name
> > not found and no default
> > driver specified
> > \_______________
> >
> > In other words it chokes at:
> > _______________
> > /
> > con =
>
DriverManager.getConnection("jdbc:odbc:movies","","");
> > \_______________
> >
> > any hints as to what I'm doing wrong?
> >
> > thanks,
> > kind regards,
> > Luke
> >
> > --
> > / / _
> > /_ /_/ /< /=
> > 0421 276 282
> >
> >> > Hi,
> >> >
> >> > I've recently started to experiment with tomcat
> 5.5.7 on windows XP,
> >> > trying to access an Access (.mdb) database.
> >> > I've set up a datasource in windowsXP
> administration tools and used
> >> > the the tomcat administration (which had to be
> installed separately)
> >> > to configure a datasource in tomcat.
> >> >
> >> > this gave me the following in 'server.xml'
> under GlobalNamingResources:
> >> > _______________
> >> > /
> >> > <Resource
> >> > name="movies"
> >> > type="javax.sql.DataSource"
> >> > password=""
> >> >
> driverClassName="sun.jdbc.odbc.JdbcOdbcDriver"
> >> > maxIdle="2"
> >> > maxWait="5000"
> >> > username=""
> >> > url="jdbc:odbc:movies"
> >> > maxActive="4"/>
> >> > \_______________
> >> >
> >> > I then got a servlet going with the following:
> >> > _______________
> >> > /
> >> > Connection con = null;
> >> > try {
> >> > // Load the Driver class file
> >> >
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> >> > out.println("Getting Connection!");
> >> > // Make a connection to the ODBC
> datasource Movie Catalog
> >> > // In this example we are opening a
> connection to the
> >> > // database with every request.
> >> > con =
>
DriverManager.getConnection("jdbc:odbc:movies","","");
> >> > if ( con == null ) {
> >> > out.println("no Connection!");
> >> > }
> >> > else {
> >> > out.println("we have a connection");
> >> > }
> >> > \_______________
> >> >
> >> > restarted tomcat and tried but get the
> following message after an
> >> > SqlException is thrown.
> >> > _______________
>
=== message truncated ===
__________________________________
Do you Yahoo!?
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]