Package cc.carm.lib.easysql.manager
Class SQLManagerImpl
- java.lang.Object
-
- cc.carm.lib.easysql.manager.SQLManagerImpl
-
- All Implemented Interfaces:
SQLManager
public class SQLManagerImpl extends java.lang.Object implements SQLManager
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.ExecutorServiceexecutorPool
-
Constructor Summary
Constructors Constructor Description SQLManagerImpl(@NotNull javax.sql.DataSource dataSource)SQLManagerImpl(@NotNull javax.sql.DataSource dataSource, @Nullable java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TableAlterBuilderalterTable(@NotNull java.lang.String tableName)对库中的某个表执行更改DeleteBuildercreateDelete(@NotNull java.lang.String tableName)创建删除操作InsertBuilder<PreparedSQLUpdateAction>createInsert(@NotNull java.lang.String tableName)创建一条插入操作InsertBuilder<PreparedSQLUpdateBatchAction>createInsertBatch(@NotNull java.lang.String tableName)创建支持多组数据的插入操作QueryBuildercreateQuery()新建一个查询ReplaceBuilder<PreparedSQLUpdateAction>createReplace(@NotNull java.lang.String tableName)创建一条替换操作ReplaceBuilder<PreparedSQLUpdateBatchAction>createReplaceBatch(@NotNull java.lang.String tableName)创建支持多组数据的替换操作TableCreateBuildercreateTable(@NotNull java.lang.String tableName)在库中创建一个表UpdateBuildercreateUpdate(@NotNull java.lang.String tableName)创建更新操作voiddebug(java.lang.String msg)java.lang.IntegerexecuteSQL(java.lang.String sql)执行一条不需要返回结果的SQL语句(多用于UPDATE、REPLACE、DELETE方法) 该方法使用 Statement 实现,请注意SQL注入风险!java.lang.IntegerexecuteSQL(java.lang.String sql, java.lang.Object[] params)执行一条不需要返回结果的预处理SQL更改(UPDATE、REPLACE、DELETE)@Nullable java.util.List<java.lang.Integer>executeSQLBatch(@NotNull java.lang.Iterable<java.lang.String> sqlBatch)执行多条不需要返回结果的SQL。java.util.List<java.lang.Integer>executeSQLBatch(@NotNull java.lang.String sql, java.lang.String... moreSQL)执行多条不需要返回结果的SQL。java.util.List<java.lang.Integer>executeSQLBatch(java.lang.String sql, java.lang.Iterable<java.lang.Object[]> paramsBatch)执行多条不需要返回结果的SQL更改(UPDATE、REPLACE、DELETE)@NotNull java.util.Map<java.util.UUID,SQLQuery>getActiveQuery()得到正使用的查询。@NotNull java.sql.ConnectiongetConnection()得到一个数据库连接实例@NotNull javax.sql.DataSourcegetDataSource()得到连接池源java.util.concurrent.ExecutorServicegetExecutorPool()java.util.logging.LoggergetLogger()booleanisDebugMode()voidsetDebugMode(@NotNull java.util.function.Supplier<@NotNull java.lang.Boolean> debugMode)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface cc.carm.lib.easysql.api.SQLManager
setDebugMode
-
-
-
-
Method Detail
-
isDebugMode
public boolean isDebugMode()
- Specified by:
isDebugModein interfaceSQLManager
-
setDebugMode
public void setDebugMode(@NotNull @NotNull java.util.function.Supplier<@NotNull java.lang.Boolean> debugMode)- Specified by:
setDebugModein interfaceSQLManager
-
debug
public void debug(java.lang.String msg)
-
getLogger
public java.util.logging.Logger getLogger()
- Specified by:
getLoggerin interfaceSQLManager
-
getExecutorPool
public java.util.concurrent.ExecutorService getExecutorPool()
-
getDataSource
@NotNull public @NotNull javax.sql.DataSource getDataSource()
Description copied from interface:SQLManager得到连接池源- Specified by:
getDataSourcein interfaceSQLManager- Returns:
- DataSource
-
getConnection
@NotNull public @NotNull java.sql.Connection getConnection() throws java.sql.SQLExceptionDescription copied from interface:SQLManager得到一个数据库连接实例- Specified by:
getConnectionin interfaceSQLManager- Returns:
- Connection
- Throws:
java.sql.SQLException- 见DataSource.getConnection()
-
getActiveQuery
@NotNull public @NotNull java.util.Map<java.util.UUID,SQLQuery> getActiveQuery()
Description copied from interface:SQLManager得到正使用的查询。- Specified by:
getActiveQueryin interfaceSQLManager- Returns:
- 查询列表
-
executeSQL
public java.lang.Integer executeSQL(java.lang.String sql)
Description copied from interface:SQLManager执行一条不需要返回结果的SQL语句(多用于UPDATE、REPLACE、DELETE方法) 该方法使用 Statement 实现,请注意SQL注入风险!- Specified by:
executeSQLin interfaceSQLManager- Parameters:
sql- SQL语句内容- Returns:
- 更新的行数
- See Also:
SQLUpdateAction
-
executeSQL
public java.lang.Integer executeSQL(java.lang.String sql, java.lang.Object[] params)Description copied from interface:SQLManager执行一条不需要返回结果的预处理SQL更改(UPDATE、REPLACE、DELETE)- Specified by:
executeSQLin interfaceSQLManager- Parameters:
sql- SQL语句内容params- SQL语句中 ? 的对应参数- Returns:
- 更新的行数
- See Also:
PreparedSQLUpdateAction
-
executeSQLBatch
public java.util.List<java.lang.Integer> executeSQLBatch(java.lang.String sql, java.lang.Iterable<java.lang.Object[]> paramsBatch)Description copied from interface:SQLManager执行多条不需要返回结果的SQL更改(UPDATE、REPLACE、DELETE)- Specified by:
executeSQLBatchin interfaceSQLManager- Parameters:
sql- SQL语句内容paramsBatch- SQL语句中对应?的参数组- Returns:
- 对应参数返回的行数
- See Also:
PreparedSQLUpdateBatchAction
-
executeSQLBatch
public java.util.List<java.lang.Integer> executeSQLBatch(@NotNull @NotNull java.lang.String sql, java.lang.String... moreSQL)Description copied from interface:SQLManager执行多条不需要返回结果的SQL。 该方法使用 Statement 实现,请注意SQL注入风险!- Specified by:
executeSQLBatchin interfaceSQLManager- Parameters:
sql- SQL语句内容moreSQL- 更多SQL语句内容- Returns:
- 对应参数返回的行数
- See Also:
SQLUpdateBatchAction
-
executeSQLBatch
@Nullable public @Nullable java.util.List<java.lang.Integer> executeSQLBatch(@NotNull @NotNull java.lang.Iterable<java.lang.String> sqlBatch)Description copied from interface:SQLManager执行多条不需要返回结果的SQL。- Specified by:
executeSQLBatchin interfaceSQLManager- Parameters:
sqlBatch- SQL语句内容- Returns:
- 对应参数返回的行数
-
createTable
public TableCreateBuilder createTable(@NotNull @NotNull java.lang.String tableName)
Description copied from interface:SQLManager在库中创建一个表- Specified by:
createTablein interfaceSQLManager- Parameters:
tableName- 表名- Returns:
TableCreateBuilder
-
alterTable
public TableAlterBuilder alterTable(@NotNull @NotNull java.lang.String tableName)
Description copied from interface:SQLManager对库中的某个表执行更改- Specified by:
alterTablein interfaceSQLManager- Parameters:
tableName- 表名- Returns:
TableAlterBuilder
-
createQuery
public QueryBuilder createQuery()
Description copied from interface:SQLManager新建一个查询- Specified by:
createQueryin interfaceSQLManager- Returns:
QueryBuilder
-
createInsertBatch
public InsertBuilder<PreparedSQLUpdateBatchAction> createInsertBatch(@NotNull @NotNull java.lang.String tableName)
Description copied from interface:SQLManager创建支持多组数据的插入操作- Specified by:
createInsertBatchin interfaceSQLManager- Parameters:
tableName- 目标表名- Returns:
InsertBuilder
-
createInsert
public InsertBuilder<PreparedSQLUpdateAction> createInsert(@NotNull @NotNull java.lang.String tableName)
Description copied from interface:SQLManager创建一条插入操作- Specified by:
createInsertin interfaceSQLManager- Parameters:
tableName- 目标表名- Returns:
InsertBuilder
-
createReplaceBatch
public ReplaceBuilder<PreparedSQLUpdateBatchAction> createReplaceBatch(@NotNull @NotNull java.lang.String tableName)
Description copied from interface:SQLManager创建支持多组数据的替换操作- Specified by:
createReplaceBatchin interfaceSQLManager- Parameters:
tableName- 目标表名- Returns:
ReplaceBuilder
-
createReplace
public ReplaceBuilder<PreparedSQLUpdateAction> createReplace(@NotNull @NotNull java.lang.String tableName)
Description copied from interface:SQLManager创建一条替换操作- Specified by:
createReplacein interfaceSQLManager- Parameters:
tableName- 目标表名- Returns:
ReplaceBuilder
-
createUpdate
public UpdateBuilder createUpdate(@NotNull @NotNull java.lang.String tableName)
Description copied from interface:SQLManager创建更新操作- Specified by:
createUpdatein interfaceSQLManager- Parameters:
tableName- 目标表名- Returns:
UpdateBuilder
-
createDelete
public DeleteBuilder createDelete(@NotNull @NotNull java.lang.String tableName)
Description copied from interface:SQLManager创建删除操作- Specified by:
createDeletein interfaceSQLManager- Parameters:
tableName- 目标表名- Returns:
DeleteBuilder
-
-