Solved

Java - database connection issue, setting the jdbc class path

Posted on 2010-08-25
5
739 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 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
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 theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

729 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