日期:2014-05-18  浏览次数:20759 次

在线,求jsp高手帮看个错误怎么改!
//数据库的操作
package   beans;

import   java.sql.*;
import   beans.Conn;

public   class   DataBase   {
        protected   Connection   conn   =   null; //Connection接口
protected   Statement   stmt   =   null; //Statement接口
protected   ResultSet   rs   =   null; //记录结果集
protected   PreparedStatement   prepstmt   =   null; //PreparedStatement接口
protected   String   sqlStr; //sql   String
protected   boolean   isConnect=true; //与数据库连接标识
       
       
   
        public   DataBase()   {
try
{
sqlStr   =   " ";
Conn   dc   =   new   Conn();
conn   =   dc.getConnection();
stmt   =   conn.createStatement();
}
catch   (Exception   e)
{
System.out.println(e);
isConnect=false;
}

}

public   Statement   getStatement()   {
return   stmt;
}

public   Connection   getConnection()   {
return   conn;
}

public   PreparedStatement   getPreparedStatement()   {
return   prepstmt;
}

public   ResultSet   getResultSet()   {
return   rs;
}


public   String   getSql()   {
return   sqlStr;
}

public   boolean   execute()   throws   Exception     {
return   false;
}

public   boolean   insert()   throws   Exception   {
return   false;
}

public   boolean   update()   throws   Exception     {
return   false;
}

public   boolean   delete()   throws   Exception     {
return   false;
}
public   boolean   query()   throws   Exception   {
return   false;
}

public   void   close()   throws   SQLException   {
if   (   stmt   !=   null   )
{
stmt.close();
stmt   =   null;
}
conn.close();
conn   =   null;
}
/*public   static   void   main(String   args[])
{
DataBase   test=new   DataBase();
        String   sqlStr;
        sqlStr= "insert   into   Userlist(UserName,PassWord)values( 'shuang11 ', 'jie11 ') ";//插入操作
                //sqlStr= "DELETE   FROM   Userlist ";//把表中的所有数据都删除了
                //sqlStr= "delete   Userlist   where   UserName= 'shuang ' ";//删除一条语句  
               
                        try{
                        int   stmt=test.stmt.executeUpdate(sqlStr);