当前位置:我的异常网» J2SE » jsp连接oracle资源没有释放掉,该如何处理
jsp连接oracle资源没有释放掉,该如何处理
www.myexceptions.net 网友分享于:2013-01-25 浏览:31次
jsp连接oracle资源没有释放掉
Class.forName( "oracle.jdbc.driver.OracleDriver ").newInstance();
String url= "jdbc:oracle:thin:@202.201.13.90:1521:exam "; //其中exam为SID,即为里面建立的数据库
String uid= "guanliyuan "; //数据库里面的用户
String pwd= "exam "; //数据库里面用户的密码
Connection con = DriverManager.getConnection(url,uid,pwd);
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs=stmt.executeQuery( "select * from JUN_RADIO "); //mis数据库里面的表
rs.last();
int recordCount=rs.getRow();
rs.first();
String[] eID=new String[recordCount];
if(rs!=null)
{
int i=0;
eID[i]=rs.getString( "QUESTIONID ");
while(rs.next())
{ i=i+1;
eID[i]=rs.getString( "QUESTIONID ");
}
}
Random rand=new Random();
String switchno; //替换用
int randno1;
int randno2;
for(int i=0;i <50;i++)
{
do
{
randno1=rand.nextInt(recordCount-1);
randno2=rand.nextInt(recordCount-1);
}while(randno1==randno2);
switchno=eID[randno1];
eID[randno1]=eID[randno2];
eID[randno2]=switchno;
}
out.print( "随机产生的题号
");
for(int i=0;i <3;i++)
{
out.println( " "+i+ " "+eID[i]+ "
");
}
out.println( "
试题如下
out.println( "
");
rs.beforeFirst();
String sid= " ";//试题ID号
for(int i=0;i <3;i++)
{
sid=eID[i];
while(rs.next())
{
if(rs.getString( "QUESTIONID ").equals(sid))
{
out.println( " "+rs.getString( "CONTENT ")+ "
");
文章评论