主题:大家好,连接2000数据库遇到问题,求救阿
您好,我在连接数据库的时候碰到了问题希望帮助解决一下:
我的jdbc设置时参照你的写的
我的源代码是
<html>
<head>
<title>通过</title>
</head>
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.sql.*" %>
<body>
<h2>
通过JDB访问数据库
</h2>
<table border=1 align="center">
<tr>
<td>用户名</td>
<td>姓名</td>
</tr>
<%
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:8080;DatabaseName=hotel";
String username="sa";
String password="";
Connection con=DriverManager.getConnection(url,username,password);
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from test");
while(rs.next())
{
%>
<tr>
<td><%=rs.getString("id")%></td>
<td><%=rs.getString("username")%></td>
</tr>
<%
}
rs.close();
con.close();
%>
</table>
</body>
</html>
可是我出现了问题:
[Microsoft][SQLServer 2000 Driver for JDBC]End of stream was detected on a read
请问是怎么回事啊??多谢站长
我的jdbc设置时参照你的写的
我的源代码是
<html>
<head>
<title>通过</title>
</head>
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.sql.*" %>
<body>
<h2>
通过JDB访问数据库
</h2>
<table border=1 align="center">
<tr>
<td>用户名</td>
<td>姓名</td>
</tr>
<%
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:8080;DatabaseName=hotel";
String username="sa";
String password="";
Connection con=DriverManager.getConnection(url,username,password);
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from test");
while(rs.next())
{
%>
<tr>
<td><%=rs.getString("id")%></td>
<td><%=rs.getString("username")%></td>
</tr>
<%
}
rs.close();
con.close();
%>
</table>
</body>
</html>
可是我出现了问题:
[Microsoft][SQLServer 2000 Driver for JDBC]End of stream was detected on a read
请问是怎么回事啊??多谢站长