File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Why JVM can't find my jdbc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Why JVM can Watch "Why JVM can New topic

Why JVM can't find my jdbc

Calvin Yan

Joined: Jun 25, 2003
Posts: 19
I have installed SqlServer2000 jdbc in my machine, set classpath as following:
c:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;c:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;c:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar
But when I run the codes like :
Connection c = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;User=administrator;Password=calvin");
catch(Exception e)
I always get the following exception:
Could anyone help me? thanks

I will do the best with what God gave me!
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Are you building a stand-alone application or using an application server?
If you're using an application server, you need to include the jar file in (for example) the web-inf/lib directory for it to be visible in a web application.
Calvin Yan

Joined: Jun 25, 2003
Posts: 19
I'm just building a stand-alone application.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8927

just do set CLASSPATH at the command prompt to see whether the jar files are set in the CLASSPATH .Just a verification
Are you using any IDE?

Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
Another way to figure it out (works with an IDE as well) is to add into your code.

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Calvin Yan

Joined: Jun 25, 2003
Posts: 19
hi Lasse,
I tried the ways you teached me, and there is no jdbc setting in it. I don't know why. I really set classpath in my operation system, but it looks different from what I printed by using {System.getProperty("java.class.path")}. Where can I set that variable?
Thanks for teaching.
Chris Brat
Ranch Hand

Joined: May 22, 2003
Posts: 108
quick thought?
when you run your app from the command line, do you include the driver jar in the -classpath option?
something like
java -cp driverjar.jar MainClass

try that

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

Calvin Y.
Hey buddy! I need you to do me a favor. Could you change your display name to meet our Naming Policy. The policy does not allow First Name Last Initial. But it does allow First Initial Last Name. For example, you could change it to Y. Calvin.
Thanks partner. Hope to see more of you around the Ranch.
BTW - You can change your display name here
See you around.
[ August 21, 2003: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
wood burning stoves
subject: Why JVM can't find my jdbc
jQuery in Action, 3rd edition