📄 database.java
字号:
package com.database;
import java.sql.*;
/**
*这里将访问数据库的各种操作封装成一个类
*/
public class DataBase {
protected Connection conn=null; //Connection接口
protected Statement stmt=null; //Statement接口
protected ResultSet rs=null; //记录结果集
protected PreparedStatement prepstmt =null;//PreparedStatement接口
protected String sql; //sql语句
protected boolean Connect=true;//与数据库连接标识
public DataBase(){
try{
sql="";
DBConnection db=new DBConnection();
conn=db.getConnection();
stmt=conn.createStatement();
}catch(Exception e){
System.out.print(e);
Connect=false;
}
}
public Connection getConn() {
return conn;
}
public boolean isConnect() {
return Connect;
}
public PreparedStatement getPrepstmt() {
return prepstmt;
}
public ResultSet getRs() {
return rs;
}
public String getSql() {
return sql;
}
public Statement getStmt() {
return stmt;
}
public boolean excute() 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;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -