• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

No suitable driver found

 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Please help me out

kaustubh
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2599
12
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kaustubh G Sharma wrote:...The below is also not working ...
Did you get an error message?
 
Jan Cumps
Bartender
Posts: 2599
12
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah. I see that David has already pointed you to the issue.
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Is that what you mean??? If yes the above is also throwing the same exception....
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2599
12
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jan Cumps
Bartender
Posts: 2599
12
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some corrections:
Kaustubh G Sharma wrote:



 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic