Class SqlDriver
java.lang.Object
org.qubership.atp.mia.repo.driver.SqlDriver
- All Implemented Interfaces:
QueryDriver<Connection>
- Direct Known Subclasses:
MySqlDriver,OracleDriver,PostgreSqlDriver
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected intprotected final ExecutorServiceprotected intprotected MetricsAggregateServiceprotected final com.google.common.cache.LoadingCache<Server, Connection> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSqlDriver(ExecutorService executorService) Constructor.protectedSqlDriver(ExecutorService executorService, int expireAfter, int cleanUpTimeout) Constructor with parameters (test usage). -
Method Summary
Modifier and TypeMethodDescriptionCreates connection.executeQuery(Server server, String query) Execute query.executeQuery(Server server, String query, int limitRecords) executeStoredProcedure(Server server, String query) Execute stored procedure.intexecuteUpdate(Server server, String query) Execute 'update'.longpoolSize()Gets pool size.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.qubership.atp.mia.repo.driver.QueryDriver
close, executeQuery, executeQueryAndGetFirstValue, getDriverType, getExecutionTimeout, initPool, initPoolCleanUp
-
Field Details
-
pool
-
executorService
-
metricsService
-
cleanUpTimeout
@Value("${db.close.delay:300}") protected int cleanUpTimeout -
expiredAfter
@Value("${db.alive.length:300}") protected int expiredAfter -
executionTimeout
@Value("${db.execution.timeout:30}") protected int executionTimeout
-
-
Constructor Details
-
SqlDriver
Constructor. -
SqlDriver
Constructor with parameters (test usage).
-
-
Method Details
-
create
Creates connection.- Specified by:
createin interfaceQueryDriver<Connection>- Parameters:
server- server- Returns:
- Connection to DB
- Throws:
com.google.common.util.concurrent.UncheckedExecutionException- which explicitly wrapsSqlConnectionFailException, which wrapsSQLExceptionwith connection error.
-
executeQuery
Description copied from interface:QueryDriverExecute query.- Specified by:
executeQueryin interfaceQueryDriver<Connection>- Parameters:
server- Serverquery- query- Returns:
- DbTable
-
executeQuery
- Specified by:
executeQueryin interfaceQueryDriver<Connection>
-
executeUpdate
Description copied from interface:QueryDriverExecute 'update'.- Specified by:
executeUpdatein interfaceQueryDriver<Connection>- Parameters:
server- serverquery- query- Returns:
- number affected rows
-
executeStoredProcedure
Description copied from interface:QueryDriverExecute stored procedure.- Specified by:
executeStoredProcedurein interfaceQueryDriver<Connection>- Parameters:
server- serverquery- query
-
poolSize
public long poolSize()Description copied from interface:QueryDriverGets pool size.- Specified by:
poolSizein interfaceQueryDriver<Connection>- Returns:
- pool size
-