Conexiune Java - MSSQL

classic Classic list List threaded Threaded
1 message Options
Alexandru Alexandru
Reply | Threaded
Open this post in threaded view
|

Conexiune Java - MSSQL

Am incercat sa ma conectez la un MS SQL server 2008 din java folosind sqljdbc_4.0.
Rulez de pe Windows XP Home, avand instalat Java SE Development Kit 7 Update 5, JRE7 si
in NetBeans 7.2 am:

public class TestSQL {


    public static void main(String[] args) {

      Connection con = null;
      CallableStatement cstmt = null;
      ResultSet rs = null;

      try {
         SQLServerDataSource ds = new SQLServerDataSource();
         ds.setUser("username");
         ds.setPassword("pass");
         ds.setServerName("192.168.126.1");
         ds.setPortNumber(90);
         ds.setDatabaseName("dbName");
         con = ds.getConnection();

       
         
      }

      catch (Exception e) {
         e.printStackTrace();
      }
    }
}

si obtin urmatorul mesaj de eroare:

Oct 09, 2012 1:55:22 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
WARNING: ConnectionID:1 ClientConnectionId: e9e69ac2-2fad-436c-a16a-6cf3ec9f9223 Prelogin error: host 192.168.126.33 port 90 Unexpected response type:72
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host 192.168.126.33, port 90 has failed. Error: "The driver received an unexpected pre-login response. Verify the connection properties and check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. This driver can be used only with SQL Server 2000 or later.". ClientConnectionId:e04debb7-3e8b-4675-9cd2-26b57b69fc85
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1667)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1654)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.Prelogin(SQLServerConnection.java:1464)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1319)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
        at com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnectionInternal(SQLServerDataSource.java:621)
        at com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnection(SQLServerDataSource.java:57)
        at testsql.TestSQL.main(TestSQL.java:35)


Ma poate ajuta cineva ? Parametrii conexiunii sunt corect introdusi, portul si adresa hostului sunt corecte.
Multumesc