关于jsp页面的更新与查询!!!
在一张jsp页面中,要同时执行更新和查询两个操作,若单单查询,没有问题,如果我先进行更新,然后再查询,页面就无法显示(页面进度条缓慢进行,最终也没显示出来),也不提示任何错误!(但如果我直接在java类中的main函数进行更新和查询,缺没有任何问题).
各位大虾相助,都搞一个星期了~~555
以下是连接数据库的类:
-----------------------------------
package com.matrix.mail;
import java.sql.*;
import java.util.Properties;
import java.io.*;
public class DBConn
{
String dbDriver= " ";
String url= " ";
String userName= " ";
String password= " ";
//String sDBDriver= "net.sourceforge.jtds.jdbc.Driver ";
//String sConnStr= "jdbc:jtds:sqlserver://192.168.150.190:1433/guestbook ";
private Connection conn=null;
private Statement stmt=null;
ResultSet rs=null;
public DBConn()
{
InputStream is = getClass().getResourceAsStream( "db.properties ");
Properties dbProps = new Properties();
try {
dbProps.load(is);
} catch (Exception e) {
System.err.println( "Can 't read the properties file. "
+ "Make sure db.properties is in the CLASSPATH ");
}
dbDriver=dbProps.getProperty( "dbDriver_jtds ");
url = dbProps.getProperty( "url_jtds ");
userName = dbProps.getProperty( "userName ");
password = dbProps.getProperty( "password ");
try
{//注册数据库驱动程序
Class.forName(dbDriver);
}
catch(
java.lang.ClassNotFoundException e)
{
System.err.println(e.getMessage());
}
}
//建立数据库连接及定义数据查询
public ResultSet executeQuery(String sql)
{
rs=null;
try
{
//创建数据库联接对象
conn=DriverManager.getConnection(url,userName,password);
stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
}
catch(
SQLException ex)
{
System.err.println( "aq.executeQuery: "+ex.getMessage());
}
return rs;
}
//定义数据操作
public void executeUpdate(String sql)
{
stmt=null;
rs=null;
try
{
conn=DriverManager.getConnection(url,userName,password);//创建数据库联接对象
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
stmt.executeUpdate(sql);
}
catch(SQLException ee)
{
System.err.println( "aq.executeUpdate: "+ee.getMessage());
}
}
public PreparedStatement getPreparedStatement(String sql)
{
PreparedStatement ps=null;
try{
conn=DriverManager.getConnection(url,userName,password);
ps=conn.prepareStatement(sql);
return ps;
}catch(SQLException ee)
{
dispose(ps);
ee.printStackTrace();
return null;
}
}
//关闭Statement
public void closeStmt()
{
try
{
stmt.close();
}
catch(SQLException &n