jsp做添删改查???

来源:百度知道 编辑:UC知道 时间:2024/05/15 12:38:48
jsp做添删改查???
不记得怎么写啊
很小的一个项目
是别人的一个毕业设计

就在一个tools包里面放个JDBC

然后直接在jsp里面调用

做添删改查

具体的代码怎么做啊

请知道的人帮下我

package bean;
import java.sql.*;
public class DataBase{
String sqlStr;
Connection con;
String str,us,pwd;
public DataBase(String str,String us,String pwd){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
this.str=str;
this.us=us;
this.pwd=pwd;
}catch(Exception ex){}
}

public boolean open(){
try{
if(con==null||con.isClosed())
con= DriverManager.getConnection("jdbc:odbc:"+str,us,pwd);
return true;
}catch(Exception ex){
return false;
}
}

public boolean close(){
try{
if(con==null)
return false;
con.close();
return true;
}catch(Exception ex){
ex.printStackTrace();
return false;
}
}

public ResultSet select(String sql){
try{
PreparedStatement st=con.prepareStatement(sql);
return st.executeQuery();
}catch(Exception e