⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pooledconnection.java

📁 这是一个采用MVC设计模式实现的网上购物的教学例子。以一种清析的结构与流程
💻 JAVA
字号:
package ConnectionPool;

import java.sql.*;

public class PooledConnection {

  // Real JDBC Connection
  private Connection connection = null;
  // boolean flag used to determine if connection is in use
  private boolean inuse = false;

  // Constructor that takes the passed in JDBC Connection
  // and stores it in the connection attribute.
  public PooledConnection(Connection value) {

    if ( value != null ) {

      connection = value;
    }
  }

  // Returns a reference to the JDBC Connection
  public Connection getConnection() {

    // get the JDBC Connection
    return connection;
  }

  // Set the status of the PooledConnection.
  public void setInUse(boolean value) {

    inuse = value;
  }

  // Returns the current status of the PooledConnection.
  public boolean inUse() {

    return inuse;
  }

  // Close the real JDBC Connection
  public void close() {

    try {

      connection.close();
    }
    catch (SQLException sqle) {

      System.err.println(sqle.getMessage());
    }
  }
}

⌨️ 快捷键说明

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