Wednesday, March 28, 2012

Problems In Connecting Using New Driver

I tried using the new MSSQL 2005 driver which I downloaded from
http://blogs.msdn.com/dataaccess/ar...28/475032.aspx.
But I had problems in connecting to the database using it.
I used the following lines to make the connection.
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con1 =
DriverManager.getConnection("jdbc:sqlserver://localhost;databaseName=BCTEST"
,
"fiorano", "fiorano123");
I got the following error.
com.microsoft.sqlserver.jdbc.SQLServerException: Failed
Logon:com.microsoft.sqls
erver.jdbc.SQLServerException: DBComms.error reading input. Context:Read
packet
header, Unexpected end of stream, readBytes:-1, negative read result,
PktNumber:
0, ReadThisPacket:0, PktDataSize:4,096
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown
Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at JDBCTestYukon.main(JDBCTestYukon.java:17)
I even tried with the simpler URL "jdbc:sqlserver://localhost" but I got the
same error.
Please help.If I use Type1 driver like below its working fine.
java.lang.Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connection1 =
java.sql.DriverManager.getConnection("jdbc:odbc:DEV329;user=sa;password=ontr
ack20");
But for the thin driver getteing the same exception..I need to upgrade
my Java version'

No comments:

Post a Comment