我是一个新手,初写JSP+JAVABEAN的网页,出现了一个很头疼的问题,请高手帮帮忙!
先帖源代码:
1,操作数据库的JAVABEAN
package library;
import java.sql.*;
public class connDB {
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
public connDB(){
try {
Class.forName( "com.jnetdirect.jsql.JSQLDriver ");
} catch (
ClassNotFoundException e) {
e.printStackTrace();
}
}
//执行查询操作,返回值为ResultSet
public ResultSet executeQuery(String sql)
{
try{
conn=DriverManager.getConnection( "jdbc:JSQLConnect://127.0.0.1:1433/database=Library ", "sa ", "sa ");
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs=stmt.executeQuery(sql);
}catch(
SQLException e)
{
System.err.println(e.getMessage());
}
return rs;
}
//执行修改操作,返回值为int
public int executeUpdate(String sql){
int result=0;
try{
conn=DriverManager.getConnection( "jdbc:JSQLConnect://127.0.0.1:1433/database=Library ", "sa ", "sa ");
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
result=stmt.executeUpdate(sql);
}catch(SQLException e)
{
System.err.println(e.getMessage());
&nb