Solved

Java - database connection issue, setting the jdbc class path

Posted on 2010-08-25
5
698 Views
Last Modified: 2012-05-10
Hello experts<

I try to connect to my data base with the following:

var dbConn = DatabaseConnectionFactory.createDatabaseConnection ('com.microsoft.sqlserver.jdbc.SQLServerDriver','jdbc:sqlserver://localhost:1433;databaseName=ngtest;','default','#####');

and ge the error:

Wrapped java.sql.SQLException: No suitable driver found for jdbc:sqlserver://localhost:1433;databaseName=ngtest

REsearching a bit tells me to set the path correctly in the class file, but are not sure how to do that.  Thoughts?

Thanks in advance!
0
Comment
Question by:robthomas09
  • 2
5 Comments
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 200 total points
ID: 33526887
you set a wrong zone : javascript.
should be : java

which tools are you using to compile your code ?
You may specify the path to the ms sql jdbc driver (sqljdbc.jar) with javac with the option : -classpath

Generaly under dev tools you specify the classpath (not only for a jdbc driver) by project.
For your applications running on the system you set the classpath as environment variable

more info here for example :
http://download-llnw.oracle.com/javase/1.3/docs/tooldocs/win32/classpath.html

if you need more help you can ask a moderator to change the zone... hmmm... I do it for you now :)
0
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 300 total points
ID: 33528224
add this line before creating db connection
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

you need to include the jar file that have com.microsoft.sqlserver.jdbc.SQLServerDriver class in your classpath,
use this tutorial as reference for jdbc
http://download.oracle.com/javase/tutorial/jdbc/overview/index.html
0
 

Author Closing Comment

by:robthomas09
ID: 33533896
Thanks!
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33535535
You're welcome! Thanks for the points!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now