aspose file tools*
The moose likes JDBC and the fly likes No suitable driver found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "No suitable driver found " Watch "No suitable driver found " New topic
Author

No suitable driver found

Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1281



Please help me out

kaustubh


No Kaustubh No Fun, Know Kaustubh Know Fun..
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

the URL is jdbc:microsoft:sqlserver://host:port not com:etc
the JDBC URL is just a string that gets passed to the driver to say "Do you support this?" and if the Driver doesn't understand the string it says 'No!' otherwise it uses the information to create a database connection.
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1281

David O'Meara wrote:the URL is jdbc:microsoft:sqlserver://host:port not com:etc
the JDBC URL is just a string that gets passed to the driver to say "Do you support this?" and if the Driver doesn't understand the string it says 'No!' otherwise it uses the information to create a database connection.



The below is also not working brother




David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

second rule of JDBC URLs: copy them from somewhere and update with your data. DO NOT write them by hand.
Go here: http://www.petefreitag.com/articles/jdbc_urls/
Copy the JDBC URL that you need and then insert your settings.
Then you'll see where you went wrong.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2516
    
  10

Kaustubh G Sharma wrote:...The below is also not working ...
Did you get an error message?


OCUP UML fundamental and ITIL foundation
youtube channel
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2516
    
  10

Ah. I see that David has already pointed you to the issue.
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1281

Jan Cumps wrote:
Kaustubh G Sharma wrote:...The below is also not working ...
Did you get an error message?


Getting the same error message
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

On a side note: I'm not sure where you're copying your code from but appears to be very old.


Don't do this, use Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); only. The code you are using is to work around an issue in class loading in Java 1.2 and we're well past that. Your code will create an instance every time and then discard it. The preferred version is almost weightless and can be called as many times as you like without impacting the application


Don't do this. Firstly it is bad form to import specific Driver code into your application as it couples your application with that database type.
Secondly, the JDBC specification requires a JDBC Driver to register itself when the class is loaded. The first line causes the class to be loaded, therefore the second line can be omitted.
Worse, it causes the Driver to be registered twice (unless that particular bug was fixed) which can in some cases be the cause of a memory leak.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Oh and finally any JDBC 4 Drivers found on the classpath are registered by the DriverManager automatically so the whole Class.forName(...) can probably be omitted.

If you want more help with the URL, and the problem is still the URL, then please post just that line of code.
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1281

David O'Meara wrote:second rule of JDBC URLs: copy them from somewhere and update with your data. DO NOT write them by hand.
Go here: http://www.petefreitag.com/articles/jdbc_urls/
Copy the JDBC URL that you need and then insert your settings.
Then you'll see where you went wrong.


I check out the above link also but didn't get it ... because the code that I put here is looking right to me.... may be there's some problem with sql server 2000 drivers because my system has already having sql server 2005 ...I think that sql server 2000 is not install properly or I have taken some wrong jars.... BTW I am connecting with the database without having any problem...Please guide me to figure the problem... Thanks

Kaustubh
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1281

made the changes that you've said to me as below..


but from the second like above it is throwing the same Exception....

"Java.sql.SQLException---No suitable driver found for jdbc:sqlserver://192.168.10.110:1433/mcard10".....

mcard10 is the name of the db and password and username is correct ....

I am confused

David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"Looking right" obviously isn't right.
I'm asking you to d the same thing I'd do myself to resolve the issue

1) Copy the JDBC URL from that page
2) replace the server, port and database name with your own
3) remove unused data such as username/password
4) compare the pair.
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1281




Is that what you mean??? If yes the above is also throwing the same exception....
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

David O'Meara wrote:"Looking right" obviously isn't right.
I'm asking you to d the same thing I'd do myself to resolve the issue

1) Copy the JDBC URL from that page
2) replace the server, port and database name with your own
3) remove unused data such as username/password
4) compare the pair.


1) jdbc:microsoft:sqlserver://host:port;databasename=name;user=yourUser;password=yourPwd
2) jdbc:microsoft:sqlserver://192.168.10.110:1433;databasename=mcard10;user=yourUser;password=yourPwd
3) jdbc:microsoft:sqlserver://192.168.10.110:1433;databasename=mcard10

Not like yours at all, is it?
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1281

run it on my local system but it is throwing the same error.... WHAT TO DO DAVID SIR ?

I want my MySql Back......................


David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

the code you pasted is not correct. Also, build the JDBC URL in one place, don't add the database later.
What JDBC URL are you using?
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1281

David O'Meara wrote:the code you pasted is not correct. Also, build the JDBC URL in one place, don't add the database later.
What JDBC URL are you using?


Din't get you sir the URL I am creating is this one.. jdbc:sqlserver://192.168.10.110:1433/mcard10
don't add the database later???
What JDBC URL are you using???
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I'm asking about this line where the database is added afterwards.
And have a look at the URL I built above, you didn't follow the steps.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42908
    
  69
Programming is all about paying attention to detail. You apparently assume that spaces are not significant in DB URLs; that's an incorrect assumption.
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1281

David O'Meara wrote:I'm asking about this line where the database is added afterwards.
And have a look at the URL I built above, you didn't follow the steps.


Sorry previously I am not getting it correctly but here also every info is coming fine... Even though there's nothing wrong with the drivers ...
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2516
    
  10

Kaustubh G Sharma wrote:...
Sorry previously I am not getting it correctly but here also every info is coming fine... Even though there's nothing wrong with the drivers ...


Not everything is fine:
Your url:
jdbc:microsoft:sqlserver://192.168.10.110:1433/mcard10

url definition for sql server (from David's url http://www.petefreitag.com/articles/jdbc_urls/ ) :
jdbc:microsoft:sqlserver://host:port;databasename=name
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1281

Jan Cumps wrote:
Kaustubh G Sharma wrote:...
Sorry previously I am not getting it correctly but here also every info is coming fine... Even though there's nothing wrong with the drivers ...


Not everything is fine:
Your url:
jdbc:microsoft:sqlserver://192.168.10.110:1433/mcard10

url definition for sql server (from David's url http://www.petefreitag.com/articles/jdbc_urls/ ) :
jdbc:microsoft:sqlserver://host:port;databasename=name


Both looks same to me....
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1281

first it was saying class not found exception... Afterwards it is saying "No suitable driver found"...What's the issue?
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1281

MICROSOFT SUPPORT SAYS:::::

Set your system CLASSPATH variable to include the following entries:
\Your installation path\Lib\Msbase.jar
\Your installation path\Lib\Msutil.jar
\Your installation path\Lib\Mssqlserver.jar
This is an example of a configured CLASSPATH variable:
CLASSPATH=.;c:\program files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;c:\program files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;c:\program files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar




But I am not able to find such directories where I can put these jar files...I have a MY SQLSERVER path in C driver Program Files Folder but I am not able to get the mentioned path in it...

and as mentioned in it I also paste the driver in C:\Temp folder but this is also not working...

http://support.microsoft.com/kb/313100
http://msdn.microsoft.com/en-us/library/ms378526.aspx
Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1281

Finally it works for me ....Some changes in the code and setting sqlserver jar into class path it is working for me...Thanks for your support and sharing information...

kaustubh


can see the working code below....


Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Kaustubh G Sharma wrote:MICROSOFT SUPPORT SAYS:::::

Set your system CLASSPATH variable to include the following entries:
\Your installation path\Lib\Msbase.jar
\Your installation path\Lib\Msutil.jar
\Your installation path\Lib\Mssqlserver.jar
This is an example of a configured CLASSPATH variable:
CLASSPATH=.;c:\program files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;c:\program files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;c:\program files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar




But I am not able to find such directories where I can put these jar files...I have a MY SQLSERVER path in C driver Program Files Folder but I am not able to get the mentioned path in it...

and as mentioned in it I also paste the driver in C:\Temp folder but this is also not working...

http://support.microsoft.com/kb/313100
http://msdn.microsoft.com/en-us/library/ms378526.aspx


Its probably worth noting that that support article is for the appallingly buggy SQL Server 2000 driver. When MS first released a JDBC driver they bought a cut of code from DataDirect (bugs and all) and no licence to fix any of these issues. So the driver remained a nasty affair for years and was used by almost no one. If you are doing much with MS SQL you should probably use their much better SQL Server 2008 equivalent or jTDS.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2516
    
  10

Some corrections:
Kaustubh G Sharma wrote:



Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1281

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: No suitable driver found