Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Java - database connection issue, setting the jdbc class path

Posted on 2010-08-25
5
Medium Priority
?
749 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 800 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:
Gurvinder Pal Singh earned 1200 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
I have a large data set and a SSIS package. How can I load this file in multi threading?
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.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

610 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