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
Solved

Java - database connection issue, setting the jdbc class path

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Stored Proc - Rewrite 42 56
Run Stored Procedure uisng ADO 5 20
SQL 2012 clustering 9 10
SQL Recursion 6 16
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…
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

808 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