tomcat+jsp+sql2000 运行1小时后变得极慢,救命! cpu:2.8G内存:512Mwin2000 server 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1、在服务器上加内存条,你的机子做服务器才512内存,太小了。2、加在Tomcat占内存量。一般Tomcat只使用128的内存,你可能通过加参数,来扩大Tomcat的内存占用量。细节你可以在网上查很多的。 %90是你的连接没有关闭。给你一段砌底关闭连接的代码吧 try { conn=sfca.common.ConnectionManager.getConnection(); try { stmt=conn.createStatement(); try { rs=stmt.executeQuery(sql); while(rs.next()) { } } finally { rs.close(); rs=null; } } finally { stmt.close(); stmt=null; } } finally { conn.close(); conn=null; } 我的代码是这样写的(伪代码):conn = null;stmt = null;rs = nulltry{ conn=sfca.common.ConnectionManager.getConnection(); stmt=conn.createStatement(); rs = stmt.executeQuery(sql); while(rs.next()) { .... }}catch(Exception e){ e.printerror();}finally{ if( rs != null ) rs.close(); if( stmt != null ) stmt.close(); if( conn != null ) conn.close();} 这样应该能够彻底关闭连接吧?是不是TOMCAT的配置问题呢?为什么会导致数据库服务器CPU忙呢?。郁闷!!各位高手,帮帮忙啊! 没有用连接池发现有3个jsp中没有关闭连接,关闭之后该问题就没有了.不知道是巧合还是真的改好了.!!为什么才3个jsp页面泄露,会导致这么快就导致这么严重的事情?(我曾尝试在某jsp页种循环1000次,让连接泄露,却也不出问题,着又是为什么呢?希望高手耐心为我解惑.谢谢了!!! jsp里面有没有调用自定义的函数或存储过程?如果存储过程或函数里面创建了非临时表,会有问题的 你试试用tomcat的连接池极大可能性是你没有关闭不用的数据库连接 iBatis报无效的列索引 Ext小问题 webwork+sitemesh中文乱码? axis2中webservice客户端调用以及相关数据类型处理的问题 关于新浪网股票实时数据问题. jxl导出excel,如何下载 在一个页面中如何将一个form的不同button对应不同的页面? 请问关于打jar包的问题 一个重大的疑问,请高手指点? SAX高手请进 诡异的J2EE连接MSSQL的问题 关于招聘
2、加在Tomcat占内存量。一般Tomcat只使用128的内存,你可能通过加参数,来扩大Tomcat的内存占用量。细节你可以在网上查很多的。
{
conn=sfca.common.ConnectionManager.getConnection();
try
{
stmt=conn.createStatement();
try
{
rs=stmt.executeQuery(sql);
while(rs.next())
{
}
}
finally
{
rs.close();
rs=null;
}
}
finally
{
stmt.close();
stmt=null;
}
}
finally
{
conn.close();
conn=null;
}
conn = null;
stmt = null;
rs = null
try
{
conn=sfca.common.ConnectionManager.getConnection();
stmt=conn.createStatement();
rs = stmt.executeQuery(sql);
while(rs.next())
{
....
}
}
catch(Exception e)
{
e.printerror();
}
finally
{
if( rs != null )
rs.close();
if( stmt != null )
stmt.close();
if( conn != null )
conn.close();}
是不是TOMCAT的配置问题呢?为什么会导致数据库服务器CPU忙呢?。
郁闷!!各位高手,帮帮忙啊!
发现有3个jsp中没有关闭连接,关闭之后该问题就没有了.
不知道是巧合还是真的改好了.!!为什么才3个jsp页面泄露,会导致这么快就导致这么严重的事情?
(我曾尝试在某jsp页种循环1000次,让连接泄露,却也不出问题,着又是为什么呢?
希望高手耐心为我解惑.
谢谢了!!!
如果存储过程或函数里面创建了非临时表,会有问题的
极大可能性是你没有关闭不用的数据库连接