I am trying to connect to SQL server from a servlet running in Tomcat
4.1. The following is the code :
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:dpt","sa","");
}catch(Exception e){e.printStackTrace(out);}
It is giving the following error on the getConnection() code :
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source
name not found and no default driver
The same code with subsequent SQL statements runs fine when used in a
stand alone Java program . I am using MS SQL Server database and set up
the DSN properly ( I guess) or else the stand alone program would not
work.
Please help.
Shyamal
Cos - 10 Mar 2006 18:00 GMT
I might be mistaken, 'cause I was working with app servers as long as a
few years ago, but it seems to be the case of hierarchy of class
loaders, utilized by Tomcat (and, I think, other app. servers).
Instead of default class loader (as in your case), you might need to
use system one. The difference is in the classpaths available to those.
If you'll google for 'Tomcat classloaders' you'll find more on that
topic. Unfortunately, I wasn't able to recall much from a top of my
head.
Cos
driftn3@yahoo.com - 14 Mar 2006 21:08 GMT
Are you using a "System", "User", for "File" type DSN? It will need to
be a System DSN for the Tomcat access it.....just a thought.
Larry
> I am trying to connect to SQL server from a servlet running in Tomcat
> 4.1. The following is the code :
[quoted text clipped - 18 lines]
>
> Shyamal
driftn3@yahoo.com - 14 Mar 2006 21:08 GMT
Are you using a "System", "User", for "File" type DSN? It will need to
be a System DSN for the Tomcat access it.....just a thought.
Larry
> I am trying to connect to SQL server from a servlet running in Tomcat
> 4.1. The following is the code :
[quoted text clipped - 18 lines]
>
> Shyamal
shyamal - 21 Mar 2006 18:39 GMT
Thanks. Indeed it needs System DSN for it to work with Tomcat.
Shyamal