为什么大量的连接不能释放?
Oracle 9i的数据库
SELECT sql_text,COUNT(*) FROM v$sql s , v$session se WHERE se.prev_hash_value =s.hash_value GROUP BY sql_text
发现sql_text重大量的下面语句不能释放
select * from code_m where (name like '%吊坠% ' or key_word like '%吊坠% ') and name <> '吊坠 '
请问如何解决,附程序
public String getRelateKeyword(String name)throws NamingException,SQLException
{
String word= " ",tempStr= " ";
Connection conn=null;
PreparedStatement pstmt=null;
ResultSet rs=null;
try
{
conn=pool.getConnection();
tempStr=getKeywordbyName(name,conn);
String sql= "select * from code_m where (name like '% "+name+ "% ' or key_word like '% "+name+ "% ') and name <> ' "+name+ " ' ";
if(!tempStr.equals( " "))
sql= "select * from code_m where (name like '% "+name+ "% ' or key_word like '% "+tempStr+ "% ') and name <> ' "+name+ " ' ";
pstmt=conn.prepareStatement(sql);
rs=pstmt.executeQuery();
while(rs.next())
{
word+=rs.getString( "name ")+ ", ";
}
}finally{
pool.cleanup(conn,pstmt,rs);
}
return word;
}
------解决方案--------------------you should close rs and conn
------解决方案--------------------conn.close()
------解决方案--------------------System.GC.Collect();
OK