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.
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.
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.
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.
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.
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
"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.
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.
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 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 ...
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
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
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...
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 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...
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.