public interface Database extends javax.inject.Provider<Database>, java.util.function.Supplier<Database>
| Modifier and Type | Method and Description |
|---|---|
void |
assertTimeSynchronized()
Convenience method, same as
assertTimeSynchronized(long, long)
with millisToWarn=10000 and millisToError=30000. |
void |
assertTimeSynchronized(long millisToWarn,
long millisToError)
Check the JVM time (and timezone) against the database and log a warning
or throw an error if they are too far apart.
|
void |
commitNow()
Cause the underlying connection to commit its transaction immediately.
|
Ddl |
ddl(String sql)
Create a DDL (schema modifying) statement for further manipulation and execution.
|
void |
dropSequenceQuietly(String sequenceName)
Convenience method to deal with mutually incompatible syntax for this.
|
void |
dropTableQuietly(String tableName)
Convenience method to deal with dropping tables that may or may not exist.
|
Flavor |
flavor()
Access information about what kind of database we are dealing with.
|
Long |
nextSequenceValue(String sequenceName)
Read the next value from a sequence.
|
Date |
nowPerApp()
Get the value that would be used if you specify an argNowPerApp() parameter.
|
Options |
options() |
void |
rollbackNow()
Cause the underlying connection to roll back its transaction immediately.
|
SqlUpdate |
toDelete(Sql sql) |
SqlUpdate |
toDelete(String sql)
Create a SQL "delete" statement for further manipulation and execution.
|
SqlInsert |
toInsert(Sql sql) |
SqlInsert |
toInsert(String sql)
Create a SQL "insert" statement for further manipulation and execution.
|
SqlSelect |
toSelect(Sql sql) |
SqlSelect |
toSelect(String sql)
Create a SQL "select" statement for further manipulation and execution.
|
SqlUpdate |
toUpdate(Sql sql) |
SqlUpdate |
toUpdate(String sql)
Create a SQL "update" statement for further manipulation and execution.
|
Connection |
underlyingConnection()
Obtain direct access to the connection being used by this instance.
|
When |
when()
A little syntax sugar to make it easier to customize your SQL based on the
specific database.
|
get@Nonnull @CheckReturnValue SqlInsert toInsert(@Syntax(value="SQL") @Nonnull String sql)
sql - the SQL to execute, optionally containing indexed ("?") or
named (":foo") parameters. To include the characters '?' or ':'
in the SQL you must escape them with two ("??" or "::"). You
MUST be careful not to pass untrusted strings in as SQL, since
this will be executed in the database.@Nonnull @CheckReturnValue SqlInsert toInsert(@Nonnull Sql sql)
@Nonnull @CheckReturnValue SqlSelect toSelect(@Syntax(value="SQL") @Nonnull String sql)
sql - the SQL to execute, optionally containing indexed ("?") or
named (":foo") parameters. To include the characters '?' or ':'
in the SQL you must escape them with two ("??" or "::"). You
MUST be careful not to pass untrusted strings in as SQL, since
this will be executed in the database.@Nonnull @CheckReturnValue SqlSelect toSelect(@Nonnull Sql sql)
@Nonnull @CheckReturnValue SqlUpdate toUpdate(@Syntax(value="SQL") @Nonnull String sql)
sql - the SQL to execute, optionally containing indexed ("?") or
named (":foo") parameters. To include the characters '?' or ':'
in the SQL you must escape them with two ("??" or "::"). You
MUST be careful not to pass untrusted strings in as SQL, since
this will be executed in the database.@Nonnull @CheckReturnValue SqlUpdate toUpdate(@Nonnull Sql sql)
@Nonnull @CheckReturnValue SqlUpdate toDelete(@Syntax(value="SQL") @Nonnull String sql)
sql - the SQL to execute, optionally containing indexed ("?") or
named (":foo") parameters. To include the characters '?' or ':'
in the SQL you must escape them with two ("??" or "::"). You
MUST be careful not to pass untrusted strings in as SQL, since
this will be executed in the database.@Nonnull @CheckReturnValue SqlUpdate toDelete(@Nonnull Sql sql)
@Nonnull @CheckReturnValue Ddl ddl(@Syntax(value="SQL") @Nonnull String sql)
sql - the SQL to execute, optionally containing indexed ("?") or
named (":foo") parameters. To include the characters '?' or ':'
in the SQL you must escape them with two ("??" or "::"). You
MUST be careful not to pass untrusted strings in as SQL, since
this will be executed in the database.@CheckReturnValue Long nextSequenceValue(@Nonnull String sequenceName)
Date nowPerApp()
void commitNow()
Options,
or it will throw a DatabaseException.void rollbackNow()
Options,
or it will throw a DatabaseException.@Nonnull Connection underlyingConnection()
Obtain direct access to the connection being used by this instance. Be very careful as this is highly likely to be unsafe and cause you great pain and suffering. This method is included to help ease into the library in large codebases where some parts still rely on direct JDBC access.
By default this method will throw a DatabaseException. If you want
to use this method you must explicitly enable it via
Options.allowConnectionAccess()
@Nonnull When when()
A little syntax sugar to make it easier to customize your SQL based on the specific database. For example:
"select 1" + db.when().oracle(" from dual")
"select " + db.when().postgres("date_trunc('day',").other("trunc(") + ") ..."void dropSequenceQuietly(String sequenceName)
Oracle: 'drop sequence x'
Derby: 'drop sequence x restrict'
"void dropTableQuietly(String tableName)
tableName - the table to be droppedvoid assertTimeSynchronized(long millisToWarn,
long millisToError)
millisToWarn - if the clocks disagree by more than this and less than
millisToError, a warning will be dropped in the logmillisToError - if the clocks disagree by more than this a
DatabaseEception will be thrownvoid assertTimeSynchronized()
assertTimeSynchronized(long, long)
with millisToWarn=10000 and millisToError=30000.Copyright © 2016. All rights reserved.