File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes No suitable driver found for JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "No suitable driver found for JDBC" Watch "No suitable driver found for JDBC" New topic
Author

No suitable driver found for JDBC

P Arunkumar
Ranch Hand

Joined: Jan 05, 2012
Posts: 119
Hi

I am using microsoft sql server2008 i download Microsoft SQL Server JDBC Driver 3.0 and i set the class path as C:\Program Files\Microsoft SQL Server JDBC Driver 3.0\sqljdbc_3.0\enu\sqljdbc4.jar; and my program is


While compiling time no error but running time iam getting no suitable driver found for “jdbc:sqlserver:SQL1:sqlexpress;” +
“database=MyDatabase;” +
“user=sa;” +
“password=Admin123″;
please solve my issue.

Thanks in advance.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19725
    
  20

Your connection String is invalid. It should be in the form jdbc:sqlserver://<HOST>:<PORT>;databaseName=<DATABASE> or jdbc:sqlserver://<HOST>\<INSTANCE>;databaseName=<DATABASE>, possibly followed by more parameters separated by semi-colons. The :<PORT> or \<INSTANCE> part can be omitted if you want to connect to the default instance on the default port (1433).
For you, assuming that you're using SQL Server Express and the instance name is SQLExpress, the connecting String becomes jdbc:sqlserver:/SQL1\SQLExpress;databaseName=MyDatabase. I wouldn't add the user name and password to the connection String; use the overloaded DriverManager.getConnection(connectionUrl, username, password) method for that.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19725
    
  20

Oh, and please KeepItDown, also in subject lines. I've replaced the all-uppercase letters in your subject line.
P Arunkumar
Ranch Hand

Joined: Jan 05, 2012
Posts: 119
Thank you very much my driver problem solved but still some errors.

while running time java Example
com.microsoft.sqlserver.jdbc.SQLserverConnection <init> SEVERE : Java Runtime Environment<JRE> version 106 is not supported by this driver. Use the sqljdbc4.jar class library,which provides support for JDBC 4.0. Java Runtime Environment <JRE> version 1.6 is not supported by this driver. Use the sqljdbc4.jar class library, which provides support for JDBC 4.0.


Please solve my issue.

Thanks in advance.

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19725
    
  20

Well, the error message gives the answer already - upgrade from the JDBC 3.0 driver to the JDBC 4.0 driver.
P Arunkumar
Ranch Hand

Joined: Jan 05, 2012
Posts: 119
Hi

Now i have downloaded jdbc 4.0 and i set the class path also now there is no error but i while running time i got the line com.microsoft.sqlserver.jdbc.SQLServerDriver

c:\desktop>javac Example.java
c:\desktop> java Example
com.microsoft.sqlserver.jdbc.SQLServerDriver
c:\desktop>

My program code is


Iam using sql server 2008 and my server name is SQL1 ,

I have created the database name as MyDatabase and my table name is MyTable.

My table having 3columns name no emp_no. i wants to see my table details.

please guide to solve my problem.

Thanks in advance.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
How are you setting the classpath? I generally advise not to use the CLASSPATH variable, but the "-cp" switch. In that case, you'd enter something like:

java -cp theJdbcDriver.jar:. Example
P Arunkumar
Ranch Hand

Joined: Jan 05, 2012
Posts: 119
Hi

I have set the class path through -cp and set CLASSPATH also still iam getting same problem it showing only com.microsoft.sqlserver.jdbc.SQLServerDriver please check my code because iam new to development filed please help me to solve this problem.


Thanks in advance.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
What, exactly, are you typing to run the program? In which directory are you, and where are the class file and the jar file?
P Arunkumar
Ranch Hand

Joined: Jan 05, 2012
Posts: 119
I just running in command prompt only
to compile javac Example.java
run java Example
iam having my java file in desktop, my class file also created in desktop and jar file is in C:\Program Files\Microsoft JDBC Driver 4.0 for SQL Server\sqljdbc_4.0\enu\sqljdbc4.jar
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Try something like

java -cp "C:\Program Files\Microsoft JDBC Driver 4.0 for SQL Server\sqljdbc_4.0\enu\sqljdbc4.jar;." Example
P Arunkumar
Ranch Hand

Joined: Jan 05, 2012
Posts: 119
I tried by using your advice, I solved that error but iam getting new error


for that i have gave my server name in the code as


Now one more error is coming that is


I checked my port number is 1433 and TCP/IP is enable and the firewall is in off.

Please help me how i can solve this problem.

Thanks in advance.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
This should give you a clue: "to the host SQL1database=MyDatabase". You're missing a semicolon.
P Arunkumar
Ranch Hand

Joined: Jan 05, 2012
Posts: 119
Really Thanks a lot. from morning on words iam struggle a lot i got the result. really so thanks a lot.

 
wood burning stoves
 
subject: No suitable driver found for JDBC