dbsqlmanager.java

来自「图书管理系统毕业设计源代码,图书管理系统毕业设计源代码图书管理系统毕业设计源代码」· Java 代码 · 共 65 行

JAVA
65
字号
/* * DBSQLManager.java * * Created on 2006年4月22日, 上午11:22 * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */package mySql;import java.sql.*;/** * * @author wang */public class DBSQLManager {    protected Connection conn=null;    protected Statement stmt=null;    protected ResultSet rs=null;    protected String sql;    /** Creates a new instance of DBSQLManager */    public DBSQLManager() {        try{            sql="";            DBConnectionManager dcm=new DBConnectionManager();            conn=dcm.getConnection();            stmt=conn.createStatement();        }        catch(Exception e){             System.out.println("出现异常:"+e);        }    }    public Statement getStmt(){ //获取执行sql语句容器        return stmt;    }    public Connection getConn(){ //获取连接        return conn;    }    public ResultSet getRs(){ //获取记录集        return rs;    }    public void setSql(String newSql){ //设置sql语句        sql=newSql;    }    public String getSql(){ //获取sql语句        return sql;    }    public void executeQuery() throws SQLException{ //执行记录查询操作        rs=stmt.executeQuery(sql);    }    public void executeUpdate() throws SQLException{ //执行记录更新操作        stmt.executeUpdate(sql);    }    public void close() throws SQLException{ //关闭        if(stmt!=null){            stmt.close();//关闭SQL容器            stmt=null;        }        conn.close();//关闭数据库容器        conn=null;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?