unable to connect to MS Sqlserver thru jsp

Hello Sir,

I tried to fetch the data from MS Sql server 2000 database.

i put the sqldriver related jar files under lib dir correctly.

when i browse the jsp

it throws this error:

javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]End of stream was detected on a read.

my code is:

<html>

<head>

<title>Content DashBoard</title>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

</head>

<body>

<%@ page contentType="text/html; charset=gb2312" language="java"%>

<%@ page import="java.sql.*" %>

<%

Connection con;

//try{

//Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();

//}catch(ClassNotFoundException e){out.print(e.getMessage()+"<br>");}

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");

Connection conn = DriverManager.getConnection

("jdbc:microsoft:sqlserver://localhost:8080;DatabaseName=trax;User=;Password=");

Statement stmt = conn.createStatement();

ResultSet columns = stmt.executeQuery("select * from content");

while(columns.next())

{

String provider = columns.getString("content");

String batchId = columns.getString("ID");

String status = columns.getString("Status");

%>

<%=provider%>

<%=batchId%>

<%=status%>

<%}%>

[1518 byte] By [Annamalaii1a] at [2007-10-3 3:10:17]
# 1

Hi,

looks like you got the wrong port number in your connection url.

It should be 1433 not 8080.

See

http://support.microsoft.com/kb/313100/

Ps. learn to use CODE TAGS in this forum when posting code.

replace

Connection conn = DriverManager.getConnection

("jdbc:microsoft:sqlserver://localhost:8080;DatabaseName=trax;User=;Password=");

with this....

Connection conn = DriverManager.getConnection

("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=trax;User=;Password=");

regards,

Owen

omcgoverna at 2007-7-14 21:01:03 > top of Java-index,Java Essentials,New To Java...
# 2
Sir,even after changing the port number to 1433 , i am getting the same error.plz provide me the solution asap.regardsvenki
Annamalaii1a at 2007-7-14 21:01:03 > top of Java-index,Java Essentials,New To Java...
# 3

The URL must stil be wrong... have a look at the web page link I gave you. They pass in the username and password differently, try that way instead.

Failing that, try downloading DBVisualizer ( may have to be a trial version ).It lets you browse databases via Jdbc.

So you can use the exact JDBC Driver jars your application will use, and work out the connection string much faster.

regards,

Owen

omcgoverna at 2007-7-14 21:01:03 > top of Java-index,Java Essentials,New To Java...