Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / March 2006

Tip: Looking for answers? Try searching our database.

Problem with servlet and SQL Server getConnection()

Thread view: 
shyamal - 10 Mar 2006 06:54 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.