Hi,
I am working on 64-bit windows7. I have installed JDK1.7.0. Have downloaded and unzipped the type 4 driver (sqljdbc4.jar) and placed it in the classpath. I am using SQL Server 2005 and its configuration enables TCP/IP at port 1433. My problem is when I execute the following code
I am getting the following exception. My database name is PhoneBook.
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused:
connect. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the p
ort, and that no firewall is blocking TCP connections to the port.".
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:171)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1033)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:817)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:700)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:842)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at CheckDB.main(CheckDB.java:15)
I even tried it in netbeans, same error. When i tried to use a JDBC-ODBC driver with a system DSN 'PhoneBook' through the following code
The error changed to
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid
string or buffer length
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.buildTypeInfo(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at CheckDB.main(CheckDB.java:15)
Somebody kindly help..!!