Home > Archive > SQL Server JDBC > March 2006 > JDBC connection for SQL Server 7.0









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author JDBC connection for SQL Server 7.0
Meenakshi

2006-03-07, 3:23 am

Hi

I am new to sql server. Currently i need to write a code to connect to SQL
Server 7.0 and call a stored procedure in the database through JDBC.
I have got this code which is for connecting to SQL Server 2000. But i dont
think the same can be used for SQL Server 7.0?
------------------------------------------------------------------------------------------------
import java.sql.*;

/**
* Microsoft SQL Server JDBC test program
*
*
http://msdn.microsoft.com/downloads...ompositedoc.xml
* http://support.microsoft.com/defaul...;EN-US;Q313100&
*/
public class Test {

public Test() throws Exception {

// Get connection
DriverManager.registerDriver(new
com.microsoft.jdbc.sqlserver.SQLServerDriver());
// Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
// Driver d = (Driver)
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();

Connection connection = DriverManager.getConnection(
// " jdbc:microsoft:sqlse
rver:// magnum:1433;User=nsk
l;Password=nskl");
// " jdbc:microsoft:sqlse
rver://magnum:1433", "nskl", "nskl");
" jdbc:microsoft:sqlse
rver://magnum:1433", "sa", "manager");
// " jdbc:oracle:thin:@CY
R1", "test", "test");

if (connection != null) {

System.out.println();
System.out.println("Successfully connected");
System.out.println();

// Meta data
DatabaseMetaData meta = connection.getMetaData();

System.out.println("Driver Information");
System.out.println("\tDriver Name: "+ meta.getDriverName());
System.out.println("\tDriver Version: "+ meta. getDriverVersion());

System.out.println("\nDatabase Information ");
System.out.println("\tDatabase Name: "+ meta. getDatabaseProductNa
me());
System.out.println("\tDatabase Version: "+
meta. getDatabaseProductVe
rsion());
// Select some data

Statement select = connection.createStatement();
ResultSet result = select.executeQuery("SELECT msisdn FROM member");

while (result.next()) {

System.out.println(result.getString(1));
}

}
} // Test

public static void main (String args[]) throws Exception {

Test test = new Test();
}

}
------------------------------------------------------------------------------------------------
When i run this code, it gives me the following error.

Error:
Exception in thread "main" java.sql.SQLException: [Microsoft][SQLServer 2000
Driver for JDBC]Error establishing socket.

Now i also came across a website which said that the SQL Server 2000 JDBC
driver downloaded from Microsoft supports only the SQL Server 2000. If you
use it on the SQL Server 7, you will get something like:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]This
version of
the JDBC driver only supports Microsoft SQL Server 2000.

Can you please let me know whats the solution for this?
What driver do i need to use to connect to SQL Server 7.0 and if so whats
the code i need to use? Can i use the same code for it or do i need to modify
it?

Thanks
Meena
Green

2006-03-07, 9:23 am

You definitely need to get the JDBC driver for SQL Server 7.0 and then
read the driver documentation for sample code on how to connect, query,
etc.

You can try this driver http://jtds.sourceforge.net/ or get from
Microsoft.

Evan T. Basalik

2006-03-09, 1:23 pm

While there are a number of JDBC drivers that will connect to SQL Server 7.0, Microsoft does not ship any. Neither the MS SQL Server 2000 JDBC driver,
nor the MS SQL Server 2005 JDBC driver will work with SQL Server 7.0.

Also, you may want to keep in mind that we have discontinued mainstream support for SQL Server 7.0, so you may want to start considering an upgrade to
at least SQL Server 2000 (http://support.microsoft.com/defaul...kb;en-us;912251)

Evan

--------------------
>Thread-Topic: JDBC connection for SQL Server 7.0
>From: =?Utf-8?B?TWVlbmFrc2hp?= < Meenakshi@discussion
s.microsoft.com>
>Subject: JDBC connection for SQL Server 7.0
>Date: Tue, 7 Mar 2006 00:28:14 -0800
>
>Hi
>
>I am new to sql server. Currently i need to write a code to connect to SQL
>Server 7.0 and call a stored procedure in the database through JDBC.
>I have got this code which is for connecting to SQL Server 2000. But i dont
>think the same can be used for SQL Server 7.0?


------------------------------------------------------------------------------------------------
>import java.sql.*;
>
>/**
> * Microsoft SQL Server JDBC test program
> *
> *
>http://msdn.microsoft.com/downloads...ompositedoc.xml
> * http://support.microsoft.com/defaul...;EN-US;Q313100&
> */
>public class Test {
>
> public Test() throws Exception {
>
> // Get connection
> DriverManager.registerDriver(new
>com.microsoft.jdbc.sqlserver.SQLServerDriver());
>// Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
>// Driver d = (Driver)
>Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
>
> Connection connection = DriverManager.getConnection(
>// " jdbc:microsoft:sqlse
rver:// magnum:1433;User=nsk
l;Password=nskl");
>// " jdbc:microsoft:sqlse
rver://magnum:1433", "nskl", "nskl");
> " jdbc:microsoft:sqlse
rver://magnum:1433", "sa", "manager");
>// " jdbc:oracle:thin:@CY
R1", "test", "test");
>
> if (connection != null) {
>
> System.out.println();
> System.out.println("Successfully connected");
> System.out.println();
>
> // Meta data
> DatabaseMetaData meta = connection.getMetaData();
>
> System.out.println("Driver Information");
> System.out.println("\tDriver Name: "+ meta.getDriverName());
> System.out.println("\tDriver Version: "+ meta. getDriverVersion());

> System.out.println("\nDatabase Information ");
> System.out.println("\tDatabase Name: "+ meta. getDatabaseProductNa
me());
> System.out.println("\tDatabase Version: "+
>meta. getDatabaseProductVe
rsion());
> // Select some data
>
> Statement select = connection.createStatement();
> ResultSet result = select.executeQuery("SELECT msisdn FROM member");
>
> while (result.next()) {
>
> System.out.println(result.getString(1));
> }
>
> }
> } // Test
>
> public static void main (String args[]) throws Exception {
>
> Test test = new Test();
> }
>
>}


------------------------------------------------------------------------------------------------
>When i run this code, it gives me the following error.
>
>Error:
>Exception in thread "main" java.sql.SQLException: [Microsoft][SQLServer 2000
>Driver for JDBC]Error establishing socket.
>
>Now i also came across a website which said that the SQL Server 2000 JDBC
>driver downloaded from Microsoft supports only the SQL Server 2000. If you
>use it on the SQL Server 7, you will get something like:
> java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]This
>version of
> the JDBC driver only supports Microsoft SQL Server 2000.
>
>Can you please let me know whats the solution for this?
>What driver do i need to use to connect to SQL Server 7.0 and if so whats
>the code i need to use? Can i use the same code for it or do i need to modify
>it?
>
>Thanks
>Meena
>



--

This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.

Don

2006-03-10, 11:23 am

Evan T. Basalik (MSFT) wrote:
> While there are a number of JDBC drivers that will connect to SQL Server 7.0, Microsoft does not ship any. Neither the MS SQL Server 2000 JDBC driver,
> nor the MS SQL Server 2005 JDBC driver will work with SQL Server 7.0.
>
> Also, you may want to keep in mind that we have discontinued mainstream support for SQL Server 7.0, so you may want to start considering an upgrade to
> at least SQL Server 2000 (http://support.microsoft.com/defaul...kb;en-us;912251)
>
> Evan
>
> --------------------
>
>
>
> ------------------------------------------------------------------------------------------------
>
>
>
> ------------------------------------------------------------------------------------------------
>
>
>
>

Another option you might consider (I used it with SQLServer 6.5 and 7.0 a
few years back) is to set up ODBC and use the jdbc:odbc driver.
Evan T. Basalik

2006-03-13, 9:23 am

One clarification - Microsoft has not ever released a JDBC driver for SQL Server 7.0 and currently has no plans to do so.

Evan

--------------------
>From: "Green" <subhash.daga@gmail.com>
>Newsgroups: microsoft.public.sqlserver.jdbcdriver
>Subject: Re: JDBC connection for SQL Server 7.0
>Date: 7 Mar 2006 07:15:31 -0800
>
>You definitely need to get the JDBC driver for SQL Server 7.0 and then
>read the driver documentation for sample code on how to connect, query,
>etc.
>
>You can try this driver http://jtds.sourceforge.net/ or get from
>Microsoft.
>
>



--

This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com