database.java

来自「 一个用JSP写的基于了B/S的图书馆管理系统」· Java 代码 · 共 74 行

JAVA
74
字号
package lms;
import java.sql.*;
import lms.*;

public class DataBase{
  protected Connection con = null;
  protected Statement stm = null;
  protected PreparedStatement prepstm = null;
  protected ResultSet rs  = null;
  protected String sqlstr ;
  private boolean isConnected = true;

  public DataBase()
  {
    try
    {
      sqlstr = "";
      //DBConnection dbcon = new DBConnection();
      DBConnect dbcon = new DBConnect();
      con = dbcon.getConnection();

      stm = con.createStatement(
          ResultSet.TYPE_SCROLL_INSENSITIVE,
          ResultSet.CONCUR_UPDATABLE);

    }
    catch(Exception ex)
    {
      System.out.println(ex);
      isConnected = false;
    }
  }

  public Statement getStatement()
  {
    return this.stm;
  }

  public Connection getConnection()
  {
    return this.con;
  }

  public PreparedStatement getPreparedStatement()
  {
    return this.prepstm;
  }

  public ResultSet getResultSet()
  {
    return this.rs;
  }

  public String getSqlstr()
  {
    return this.sqlstr;
  }

  public void close() throws SQLException
  {
    if (stm !=null){
      stm.close();
      stm = null;
    }
    con.close();
    con = null;
  }

  public static void main(String[] args)
  {
    new DataBase();
  }
}

⌨️ 快捷键说明

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