請教關於資料庫連線的問題

lxglgh發表於2005-10-14
小弟最近用jsp開發網站了一個網站,放在萬網的虛擬主機,主機是linux+mysql,當我的程式執行一段時間後,就出現如下錯誤提示:

User '****' has exceeded the 'max_connections' resource (current value: 60)

下面是我用來測試的頁面:
(當該頁面重新整理幾十次後,就會報錯,程式無法正確讀取資料,有用過虛擬主機的朋友,請指點,謝謝)


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

<%@ page contentType="text/html;charset=gb2312"%>
<%
//ArrayList al=null;
Connection conn=null;
Statement stmt=null;
ResultSet resultset1=null;

try
{
//String DBurl = "";
String DBurl = "這裡隱藏,連線沒問題";
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
conn = DriverManager.getConnection(DBurl);
stmt = conn.createStatement();
}
catch(SQLException sqlexception)
{
System.out.println(sqlexception.toString());
}
String s4 = "SELECT * FROM info";

resultset1 = stmt.executeQuery(s4);
int i=0;
for(; resultset1.next() && i<=100;i++)
{


%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<%=resultset1.getString("topic")%>
<br>
<%
}

%>
<%
try
{
resultset1.close();
stmt.close();
conn.close();
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
%>
<body>

</body>
</html>

相關文章