程序包 cn.myafx.data

类 Database

java.lang.Object
cn.myafx.data.Database
所有已实现的接口:
IDatabase, AutoCloseable

public abstract class Database extends Object implements IDatabase
  • 字段详细资料

  • 构造器详细资料

    • Database

      public Database()
  • 方法详细资料

    • isClose

      public boolean isClose()
      is close
      指定者:
      isClose 在接口中 IDatabase
      返回:
      boolean
    • isTransaction

      public boolean isTransaction()
      is transaction
      指定者:
      isTransaction 在接口中 IDatabase
      返回:
      boolean
    • getConnection

      protected abstract Connection getConnection() throws Exception
      getConnection
      返回:
      Connection
      抛出:
      Exception
    • encodeColumn

      protected abstract String encodeColumn(String column)
      encodeColumn
      参数:
      column - name
      返回:
      mysql: `column`, ms sqlserver: [column]
    • open

      public void open() throws Exception
      open
      指定者:
      open 在接口中 IDatabase
      抛出:
      Exception
    • beginTransaction

      public void beginTransaction() throws Exception
      begin transaction
      指定者:
      beginTransaction 在接口中 IDatabase
      抛出:
      Exception
    • beginTransaction

      public void beginTransaction(IsolationLevel level) throws Exception
      begin transaction
      指定者:
      beginTransaction 在接口中 IDatabase
      参数:
      level - IsolationLevel
      抛出:
      Exception
    • commit

      public void commit() throws Exception
      commit
      指定者:
      commit 在接口中 IDatabase
      抛出:
      Exception
    • rollback

      public void rollback() throws Exception
      rollback
      指定者:
      rollback 在接口中 IDatabase
      抛出:
      Exception
    • close

      public void close() throws Exception
      close
      指定者:
      close 在接口中 AutoCloseable
      抛出:
      Exception
    • execute

      public int execute(String sql, Object... param) throws Exception
      execute sql
      指定者:
      execute 在接口中 IDatabase
      参数:
      sql - update/delete/insert; param: ? or ${name} or #{name}
      param - update tb set name = ? where id = ? param is Object[]; update tb set name = ${mame} where id = ${id} param is model or Map<String, Object>
      返回:
      int
      抛出:
      Exception
    • queryOne

      public <T> T queryOne(String sql, Class<T> clazz, Object... param) throws Exception
      query first model
      指定者:
      queryOne 在接口中 IDatabase
      类型参数:
      T - model
      参数:
      sql - select sql; param: ? or ${name} or #{name}
      clazz - T.class
      param - select id, name from tb where id = ? param is Object[]; select id, name from tb where id = ${id} param is model or Map<String, Object>
      返回:
      first model
      抛出:
      Exception
    • queryList

      public <T> List<T> queryList(String sql, Class<T> clazz, Object... param) throws Exception
      query List
      指定者:
      queryList 在接口中 IDatabase
      类型参数:
      T - model
      参数:
      sql - select sql; param: ? or ${name} or #{name}
      clazz - T.class
      param - select id, name from tb where id = ? param is Object[]; select id, name from tb where id = ${id} param is model or Map<String, Object>
      返回:
      List
      抛出:
      Exception
    • queryOneMap

      public Map<String,Object> queryOneMap(String sql, Object... param) throws Exception
      query first Map<String, Object>
      指定者:
      queryOneMap 在接口中 IDatabase
      参数:
      sql - select sql; param: ? or ${name} or #{name}
      param - select id, name from tb where id = ? param is Object[]; select id, name from tb where id = ${id} param is model or Map<String, Object>
      返回:
      first Map<String, Object>
      抛出:
      Exception
    • queryListMap

      public List<Map<String,Object>> queryListMap(String sql, Object... param) throws Exception
      query List Map<String, Object>
      指定者:
      queryListMap 在接口中 IDatabase
      参数:
      sql - select sql; param: ? or ${name} or #{name}
      param - select id, name from tb where id = ? param is Object[]; select id, name from tb where id = ${id} param is model or Map<String, Object>
      返回:
      List Map String, Object
      抛出:
      Exception
    • get

      public <TModel> TModel get(Class<TModel> clazz, Map<String,Object> param) throws Exception
      get first model
      指定者:
      get 在接口中 IDatabase
      类型参数:
      TModel - Model
      参数:
      clazz - TModel.class
      param - where param
      返回:
      first Model
      抛出:
      Exception
    • getList

      public <TModel> List<TModel> getList(Class<TModel> clazz, Map<String,Object> param) throws Exception
      get List model
      指定者:
      getList 在接口中 IDatabase
      类型参数:
      TModel - Model
      参数:
      clazz - TModel.class
      param - where param
      返回:
      List Model
      抛出:
      Exception
    • add

      public int add(String table, Map<String,Object> param) throws Exception
      add row
      指定者:
      add 在接口中 IDatabase
      参数:
      table - table name
      param - insert param
      返回:
      int
      抛出:
      Exception
    • add

      public <TModel> int add(TModel m, String[] ignore) throws Exception
      add model
      指定者:
      add 在接口中 IDatabase
      类型参数:
      TModel - Model
      参数:
      m - model
      ignore - ignore model property name
      返回:
      int
      抛出:
      Exception
    • update

      public int update(String table, Map<String,Object> setParam, Map<String,Object> whereParam) throws Exception
      update
      指定者:
      update 在接口中 IDatabase
      参数:
      table - table name
      setParam - update param
      whereParam - where param
      返回:
      int
      抛出:
      Exception
    • update

      public <TModel> int update(Class<TModel> clazz, Map<String,Object> setParam, Map<String,Object> whereParam) throws Exception
      update
      指定者:
      update 在接口中 IDatabase
      类型参数:
      TModel - Model
      参数:
      clazz - Model.class
      setParam - update param
      whereParam - where param
      返回:
      int
      抛出:
      Exception
    • delete

      public int delete(String table, Map<String,Object> whereParam) throws Exception
      delete
      指定者:
      delete 在接口中 IDatabase
      参数:
      table - table name
      whereParam - where param
      返回:
      int
      抛出:
      Exception
    • delete

      public <TModel> int delete(Class<TModel> clazz, Map<String,Object> whereParam) throws Exception
      delete
      指定者:
      delete 在接口中 IDatabase
      类型参数:
      TModel - Model
      参数:
      clazz - Model.class
      whereParam - where param
      返回:
      int
      抛出:
      Exception