请教大虾:
<%@ page language="java" contentType="text/html;charset=gb2312"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="com.a123.DBTool.*"%><html>
<head>
<TITLE></TITLE>
</head>
<body>
<%
String sql = "select name,password from users";
Connection con = null;
Statement stmt = null;
ResultSet rst = null;
try
{
con = DBConnect.fetchConnection();
if(con != null)
{
out.println("数据库连接成功!");
}
stmt = con.createStatement();
rst = stmt.executeQuery(sql);
while(rst.next())
{
out.println("<p>"+rst.getString(1)+"</p>");
out.println("<p>"+rst.getString(2)+"</p>");
out.println("*********************************");
}
rst.close();
stmt.close();
con.close();
}
catch(SQLException e)
{
//
out.println(e.getMessage());
out.println("execute faile01!!!");
}
catch(Exception ee)
{
//
out.println("execute faile02!!!");
}
finally
{
if(con != null)
DBConnect.releaseConneciont(con);
}
%>
</body>
</html>运行这个jsp页面时出现以下异常:
[Microsoft][SQLServer 2000 Driver for JDBC]Object has been closed.???
请问各位大虾,问题出在哪了?
谢谢!
<%@ page language="java" contentType="text/html;charset=gb2312"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="com.a123.DBTool.*"%><html>
<head>
<TITLE></TITLE>
</head>
<body>
<%
String sql = "select name,password from users";
Connection con = null;
Statement stmt = null;
ResultSet rst = null;
try
{
con = DBConnect.fetchConnection();
if(con != null)
{
out.println("数据库连接成功!");
}
stmt = con.createStatement();
rst = stmt.executeQuery(sql);
while(rst.next())
{
out.println("<p>"+rst.getString(1)+"</p>");
out.println("<p>"+rst.getString(2)+"</p>");
out.println("*********************************");
}
rst.close();
stmt.close();
con.close();
}
catch(SQLException e)
{
//
out.println(e.getMessage());
out.println("execute faile01!!!");
}
catch(Exception ee)
{
//
out.println("execute faile02!!!");
}
finally
{
if(con != null)
DBConnect.releaseConneciont(con);
}
%>
</body>
</html>运行这个jsp页面时出现以下异常:
[Microsoft][SQLServer 2000 Driver for JDBC]Object has been closed.???
请问各位大虾,问题出在哪了?
谢谢!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货