Class JdbcDb
Collections.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanShould the JDBC connection be set to autoCommit.protected booleanFor MySQL only, set this to false to turn off SQL_CALC_FOUND_ROWS and SELECT FOUND_ROWS()protected charUrls to DDL files that should be executed on startup of this Db.protected StringThe JDBC driver class name.protected intprotected StringThe JDBC password.protected intThe maximum number of connections in the JDBC Connection pool, defaults to 50.protected charprotected StringThe JDBC url.protected StringThe JDBC username.Fields inherited from class io.inversion.Db
bootstrap, collections, dryRun, endpointPath, excludeColumns, includeColumns, includeTables, log, name, reservedParams, type -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected DataSourcevoidvoidio.inversion.Resultsprotected voidprotected voiddoStartup(io.inversion.Api api)Shortcut for getConnection(true);getConnection(boolean managed)Returns a JDBC connection to the underlying JDBC db.protected ConnectiongetConnection0(boolean managed)intgetPass()intgetType()getUrl()getUser()booleanvoidsetIdleConnectionTestPeriod(int idleConnectionTestPeriod)voidsetPoolMax(int poolMax)withAutoCommit(boolean autoCommit)withColumnQuote(char columnQuote)withConfig(String driver, String url, String user, String pass)withDdlUrl(String... ddlUrl)withDriver(String driver)withStringQuote(char stringQuote)Methods inherited from class io.inversion.Db
beautifyCollectionName, beautifyName, buildRelationships, castDbOutput, castJsonInput, castJsonInput, configApi, configDb, doShutdown, filterOutJsonProperty, getCollectionByTableName, getCollections, getEndpointPath, getHref, getKey, getName, getProperty, isBootstrap, isDryRun, isRunning, isType, makeRelationshipName, mapTo, mapToColumnNames, mapToJsonNames, patch, removeCollection, select, shutdown, shutdown, startup, upsert, withBootstrap, withCollection, withCollections, withDryRun, withEndpointPath, withExcludeColumns, withIncludeColumns, withIncludeTable, withIncludeTables, withName
-
Field Details
-
ddlUrls
Urls to DDL files that should be executed on startup of this Db. -
stringQuote
protected char stringQuote -
columnQuote
protected char columnQuote -
driver
The JDBC driver class name. -
url
The JDBC url.Generally you will want to have this value dependency inject this at runtime by setting "${name}.url=${MY_DB_URL}" somewhere where it can be discovered by
Config...for example as an environment variable or in an inversion.properties file.- See Also:
Config,Configuration
-
user
The JDBC username.Generally you will want to have this value dependency inject this at runtime by setting "${name}.user=${MY_DB_USER_NAME}" somewhere where it can be discovered by
Config...for example as an environment variable or in an inversion.properties file.- See Also:
Config,Configuration
-
pass
The JDBC password.Generally you will want to have this value dependency inject this at runtime by setting "${name}.user=${MY_DB_USER_NAME}" somewhere where it can be discovered by
Config...for example as an environment variable or in an inversion.properties file.- See Also:
Config,Configuration
-
poolMax
protected int poolMaxThe maximum number of connections in the JDBC Connection pool, defaults to 50. -
idleConnectionTestPeriod
protected int idleConnectionTestPeriod -
autoCommit
protected boolean autoCommitShould the JDBC connection be set to autoCommit.By default, autoCommit is false because the system is setup to execute all sql statements for a single Request inside of one transaction that commits just before the root Response is returned to the caller.
-
calcRowsFound
protected boolean calcRowsFoundFor MySQL only, set this to false to turn off SQL_CALC_FOUND_ROWS and SELECT FOUND_ROWS()
-
-
Constructor Details
-
JdbcDb
public JdbcDb() -
JdbcDb
-
JdbcDb
-
JdbcDb
-
-
Method Details
-
doStartup
protected void doStartup(io.inversion.Api api)- Overrides:
doStartupin classio.inversion.Db<JdbcDb>
-
doShutdown
protected void doShutdown()- Overrides:
doShutdownin classio.inversion.Db<JdbcDb>
-
getType
- Overrides:
getTypein classio.inversion.Db<JdbcDb>
-
doSelect
public io.inversion.Results doSelect(io.inversion.Collection coll, List<io.inversion.rql.Term> columnMappedTerms) throws io.inversion.ApiException- Specified by:
doSelectin classio.inversion.Db<JdbcDb>- Throws:
io.inversion.ApiException
-
doUpsert
public List<String> doUpsert(io.inversion.Collection table, List<Map<String,Object>> rows) throws io.inversion.ApiException- Specified by:
doUpsertin classio.inversion.Db<JdbcDb>- Throws:
io.inversion.ApiException
-
doPatch
public void doPatch(io.inversion.Collection table, List<Map<String,Object>> rows) throws io.inversion.ApiException- Overrides:
doPatchin classio.inversion.Db<JdbcDb>- Throws:
io.inversion.ApiException
-
delete
public void delete(io.inversion.Collection table, List<Map<String,Object>> columnMappedIndexValues) throws io.inversion.ApiException- Specified by:
deletein classio.inversion.Db<JdbcDb>- Throws:
io.inversion.ApiException
-
getConnection
Shortcut for getConnection(true);- Returns:
- a connection
- Throws:
io.inversion.ApiException
-
getConnection
Returns a JDBC connection to the underlying JDBC db.If managed is true the Connection is shared on the ThreadLocal with autoCommit managed by this Db and an EngineListener. Callers should NOT close this connection. It will not create a connection pool leak. All managed connections attached to the ThreadLocal are closed/returned to the pool when the Engine finishes serving a s Request.
If managed is false, a completely new Connection is returned.
- Parameters:
managed- should this be a net new collection or a pool connection that is automatically closed when the Request ends- Returns:
- a Connection
- Throws:
io.inversion.ApiException
-
getConnection0
- Throws:
io.inversion.ApiException
-
createConnectionPool
- Throws:
Exception
-
buildCollections
public void buildCollections() throws io.inversion.ApiException- Overrides:
buildCollectionsin classio.inversion.Db<JdbcDb>- Throws:
io.inversion.ApiException
-
withType
- Overrides:
withTypein classio.inversion.Db<JdbcDb>
-
withConfig
-
getDriver
-
withDriver
-
getUrl
-
withUrl
-
getUser
-
withUser
-
getPass
-
withPass
-
getPoolMax
public int getPoolMax() -
setPoolMax
public void setPoolMax(int poolMax) -
getIdleConnectionTestPeriod
public int getIdleConnectionTestPeriod() -
setIdleConnectionTestPeriod
public void setIdleConnectionTestPeriod(int idleConnectionTestPeriod) -
withStringQuote
-
withColumnQuote
-
quoteCol
-
quoteStr
-
withDdlUrl
-
isAutoCommit
public boolean isAutoCommit() -
withAutoCommit
-