Hello All, I am trying to use Microsoft JDBC driver for SQL Server 2000. Here is my code public class Connect{ private java.sql.Connection con = null; private final String url = "jdbc:microsoft:sqlserver://"; private final String serverName= "localhost"; private final String portNumber = "80"; private final String databaseName= "pubs"; private final String userName = "USERID"; private final String password = "PASSWORD"; // Informs the driver to use server a side-cursor, // which permits more than one active statement // on a connection. private final String selectMethod = "cursor";
I am able to find the driver and all my jar files are in the classpath.I am getting the error.
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]End of stream was detected on a read. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source ) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Sour ce) at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Sou rce) at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown S ource) at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source) at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source) at java.sql.DriverManager.getConnection(DriverManager.java:517) at java.sql.DriverManager.getConnection(DriverManager.java:177) at Connect.getConnection(Connect.java:24) at Connect.displayDbProperties(Connect.java:41) at Connect.main(Connect.java:77) Error Trace in getConnection() : [Microsoft][SQLServer 2000 Driver for JDBC]End of stream was detected on a read. Error: No active Connection
Please Help Me! Thanks
[edit: urgent removed from subject] [ December 05, 2006: Message edited by: Bear Bibeault ]
Hi , In getConnectionUrl() method , you append the USERID and PASSWORD also . In the getConnection() method , pass the above string only . Don't pass userID and password seperately . Hope it works . Mayank
Ruchi Verma
Greenhorn
Joined: Mar 28, 2002
Posts: 9
posted
0
Hello Mayank, Thanks for the response. I have changed the string as private String getConnectionUrl(){ return url+serverName+":"+portNumber+";databaseName="+databaseName+";selectMethod="+selectMethod+";User="+userName+";Password="+password+""; }
private java.sql.Connection getConnection(){ try{ Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); con = java.sql.DriverManager.getConnection(getConnectionUrl()); if(con!=null) System.out.println("Connection Successful!"); }catch(Exception e){ e.printStackTrace(); System.out.println("Error Trace in getConnection() : " + e.getMessage()); } return con; } But I am still getting the same error Let me know
Mayank C
Greenhorn
Joined: Jul 18, 2002
Posts: 7
posted
0
Hi Ruchi, There don't seem to be a problem with your code.Maybe , you are not including the correct JAR file . You can verify this . Also , make sure the driver is registered . Give println() after Class.forName(). Mayank
Mayank C
Greenhorn
Joined: Jul 18, 2002
Posts: 7
posted
0
Hi Ruchi, I tried your code to connect to Oracle . It works fine . So , there might be JAR file problem or Driver problem . Check whether you can use the particular Driver . Some method is there in DriverManager Class , you can check it . Mayank If you can mail me the jar file , I can check it from here . mayankc@mascotsystems.com
Ruchi Verma
Greenhorn
Joined: Mar 28, 2002
Posts: 9
posted
0
Thanks Mayank, The program works for me. My installation for SQL Server was not fine. Thanks again for the help
Hi, I am getting the same error. Its not because your instalation was wrong. Read this: Also, if possible please explain what it exactly means. CAn someone give a more understandable explaination. Now will try using another driver. http://www.mcse.ms/archive90-2005-9-1649153.html
Thanks & Regards,
"I may not have gone where I intended to go, but I think I have ended up where I needed to be"<br /> <br />"He felt that his whole life was some kind of dream and he sometimes wondered whose it was and whether they were enjoying it"<br /> <br />--by Douglas Adams<br /> <br />[SCJP - 96%, SCWCD - 88%, SCBCD - May 2008]
I am also facing the same problem. It is working fine when both are at the same machine But creating problem when accessed from diffrent machine from Tomcat 4.1.34. And there is no firewall installed in between the PCs.