Forums Register Login

Error in Connecting to SQL Server 2000 database

+Pie Number of slices to send: Send
Hi,
I am building a project in struts.I am using Sql Server 2000 database for backend.
I am getting an exception of"No Suitable Driver" when i am trying to connect to database.
I have successfully build the User DSN say "attendance" using ODBC.
I have used following driver to connect to database:

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
DriverManager.getConnection("jdbc:odbc:attendance","sa","");

Please tell me where i am going wrong.
Please guide me to connect to database.

ThankYou.
+Pie Number of slices to send: Send
Hi,

Did you include the sqljdbc jar file in libraries ? Kindly check for sqljdbc.jar file in your project's lib folder, if its not there

you can get it from

http://www.microsoft.com/downloads/details.aspx?familyid=e22bc83b-32ff-4474-a44a-22b6ae2c4e17&displaylang=en
+Pie Number of slices to send: Send
Hi Ujwal thanks for your help.
I have included sqljdbc.jar in the path but that doesn't work.
I change the code to:

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con=DriverManager.getConnection("jdbc:sqlserver://localhost;databaseName=attendance","sa","");

Now it is giving an error:
Unable to Initialize Data Source (com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect)

Please help.

Is there any other way to connect to SQL Server 2000?
+Pie Number of slices to send: Send
See whether "attendance" database/DSN exist or not
+Pie Number of slices to send: Send
A DSN should not be required. Why do you want to use ODBC?

Make sure your database instance is configured to accept connections over TCP/IP (for SQL Server 2000 this should be the default case) and make sure it is configured to support SQL Server authentication (by default this is not the case).
+Pie Number of slices to send: Send
Hi paul,

Can you tell me how to progress.
can you give me a code to connect.I am not using ODBC
+Pie Number of slices to send: Send
 


I am not using ODBC


Ah - re-read your second post. I just noticed you were using ODBC in your initial question. Sorry.


Can you tell me how to progress.
can you give me a code to connect


Your code looks OK. Have you checked the configuration of your server for the things I suggested?
+Pie Number of slices to send: Send
Hi Paul,
What about the port number and chances of its being block by firewall ?
+Pie Number of slices to send: Send
I would be very surprised if the port number had been changed and in that instance I'd expect the connection to time out, rather than being refused. The exception message would also be different if a Firewall prevented it - the message would be something like "software caused connection abort". Given SQL Server 2000 is not configured to accept connections using SQL Server authentication by default I would think my second suggestion is the more likely one.
+Pie Number of slices to send: Send
Hi,
The error of TCP/IP has been removed.Now I am getting an error of:
No Suitable Driver for jdbc:sqlserver://localhost;databaseName=attendance","sa",""

Which type of Driver it is talking about.Can you explain..I have included sqljdbc.jar in the libraries but still i am getting the above error.
Can you tell me about driver.
Thanks
+Pie Number of slices to send: Send
You get that error for one of two reasons:
  • There is no JDBC driver in your classpath
  • The JDBC url you are using is not one supported by any of the drivers in your classpath


  • Reading the driver documentation the syntax for the urls is:

    so your URL looks OK, which means you must not have the driver jar files in your classpath.
    +Pie Number of slices to send: Send
    Please tell me about the jar files to be included in Classpath and from where i can download that?
    +Pie Number of slices to send: Send
    Here it is.
    +Pie Number of slices to send: Send
    I am getting the error:
    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.

    I have included all jar file.I have checked that TCP/IP is enabled in my system.My system is a standalone computer which is not connected to any network.Please help me in resolving the problem
    +Pie Number of slices to send: Send
     

    mohsin sheikh wrote:I am getting the error:
    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.

    I have included all jar file.I have checked that TCP/IP is enabled in my system.My system is a standalone computer which is not connected to any network.Please help me in resolving the problem



    Do you use a firewall?
    +Pie Number of slices to send: Send
    No.But i used Avast antivirus
    +Pie Number of slices to send: Send
    Check that is not stopping the connection. Also worth checking what patch level SQL Server is at, some (very early) versions had issues in their tcp/ip DLLs.
    Look ma! I'm selling my stuff!
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com


    reply
    reply
    This thread has been viewed 2104 times.
    Similar Threads
    RAD 7.5.0 - Data Perspective - This driver is locked for use with embedded applications
    Problem in connecting to database
    Wrong time retrieved in the resultset- MS SQL Server 2000
    Error using JTDS Driver
    Use MS SQL Server 2000 JDBC driver with WSAD 4.0
    More...

    All times above are in ranch (not your local) time.
    The current ranch time is
    Mar 29, 2024 02:42:34.