类 DataHelper

java.lang.Object
com.gdxsoft.easyweb.datasource.DataHelper

public class DataHelper extends Object

这是一个与数据库联系的类,它与数据库连接,数据库查询,插入更新.

它是其它与数据库联系类的超类.

  • 构造器详细资料

  • 方法详细资料

    • closeAllDataSources

      public static void closeAllDataSources()
      Close all datasources created and clear the DATASOURCES map to avoid classloader leaks on webapp reload.
    • getConnection

      public Connection getConnection()
    • setConnection

      public void setConnection(Connection connection)
      外部设置 数据库连接
      参数:
      connection -
    • connect

      public boolean connect() throws Exception
      连接到数据库 优化:在获取锁前先检查缓存,减少不必要的同步开销。
      返回:
      抛出:
      Exception
    • getStatement

      public Statement getStatement() throws Exception
      获取 Statement 对象
      返回:
      抛出:
      Exception
    • getPreparedStatement

      public PreparedStatement getPreparedStatement(String sql) throws Exception
      获取 PreparedStatement 对象
      参数:
      sql -
      返回:
      抛出:
      Exception
    • getPreparedStatementAutoIncrement

      public PreparedStatement getPreparedStatementAutoIncrement(String sql) throws Exception
      获取 PreparedStatement 对象,并且设置为自动返回自增主键
      参数:
      sql -
      返回:
      抛出:
      Exception
    • getCallableStatement

      public CallableStatement getCallableStatement(String sql) throws Exception
      获取 CallableStatement 对象
      参数:
      sql -
      返回:
      抛出:
      Exception
    • closeDataSource

      public static void closeDataSource(String configName)
      关闭指定名称的连接池并清理缓存
      参数:
      configName - 配置名称,如 "sqlprofiler_1"
    • close

      public void close()
      关闭数据库连接
    • getErrorMsg

      public String getErrorMsg()
      获取错误信息
      返回: