public class Session
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Session.AbstractResultSetReader
Reads a JDBC-result-set.
|
static interface |
Session.ConnectionFactory
Connection factory.
|
static interface |
Session.ResultSetReader
Reads a JDBC-result-set.
|
Modifier and Type | Field and Description |
---|---|
static Logger |
_log
The logger.
|
protected java.lang.ThreadLocal<java.sql.Connection> |
connection
Hold a connection for each thread.
|
protected Session.ConnectionFactory |
connectionFactory
Connection factory.
|
DBMS |
dbms
The DBMS.
|
java.lang.String |
dbUrl
The dbUrl (
null if unknown) |
protected java.util.concurrent.atomic.AtomicBoolean |
down |
java.lang.String |
driverClassName
The DBMS.
|
static long |
lastUpdateTS |
java.lang.Object |
MD_GETCOLUMNS_LOCK |
WorkingTableScope |
scope
Scope of temporary tables.
|
Constructor and Description |
---|
Session(javax.sql.DataSource dataSource,
DBMS dbms,
java.lang.Integer isolationLevel)
Constructor.
|
Session(javax.sql.DataSource dataSource,
DBMS dbms,
java.lang.Integer isolationLevel,
WorkingTableScope scope,
boolean transactional)
Constructor.
|
Session(javax.sql.DataSource dataSource,
DBMS dbms,
java.lang.Integer isolationLevel,
WorkingTableScope scope,
boolean transactional,
boolean local)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkQuery(java.lang.String sql)
Checks SQL query.
|
void |
commitAll()
Commits all connections.
|
java.sql.Connection |
createNewConnection()
Create a new connection.
|
void |
disableMetaDataChecking() |
long |
execute(java.lang.String sql)
Executes a SQL-Statement without returning any result.
|
long |
execute(java.lang.String sql,
java.lang.Object cancellationContext,
boolean acceptQueries)
Executes a SQL-Statement without returning any result.
|
void |
executeQuery(java.io.File sqlFile,
Session.ResultSetReader reader,
boolean withExplicitCommit)
Executes a SQL-Query (SELECT).
|
long |
executeQuery(java.lang.String sqlQuery,
Session.ResultSetReader reader)
Executes a SQL-Query (SELECT).
|
long |
executeQuery(java.lang.String sqlQuery,
Session.ResultSetReader reader,
boolean withExplicitCommit)
Executes a SQL-Query (SELECT).
|
long |
executeQuery(java.lang.String sqlQuery,
Session.ResultSetReader reader,
java.lang.String alternativeSQL,
java.lang.Object context,
long limit)
Executes a SQL-Query (SELECT).
|
long |
executeQuery(java.lang.String sqlQuery,
Session.ResultSetReader reader,
java.lang.String alternativeSQL,
java.lang.Object context,
long limit,
boolean withExplicitCommit)
Executes a SQL-Query (SELECT).
|
long |
executeQuery(java.lang.String sqlQuery,
Session.ResultSetReader reader,
java.lang.String alternativeSQL,
java.lang.Object context,
long limit,
int timeout,
boolean withExplicitCommit)
Executes a SQL-Query (SELECT) with timeout.
|
int |
executeUpdate(java.lang.String sqlUpdate)
Executes a SQL-Update (INSERT, DELETE or UPDATE).
|
int |
executeUpdate(java.lang.String sqlUpdate,
java.lang.Object[] parameter)
Executes a SQL-Update (INSERT, DELETE or UPDATE) with parameters.
|
java.util.List<java.lang.String> |
getCliArguments()
Gets CLI connection arguments (UI support)
|
java.sql.Connection |
getConnection()
Gets the connection for the current thread.
|
java.lang.String |
getConnectionStats() |
InlineViewStyle |
getInlineViewStyle()
Returns a suitable
InlineViewStyle for this session. |
java.lang.String |
getIntrospectionSchema()
Gets optional schema for database analysis.
|
boolean |
getLogStatements()
Log statements?
|
java.sql.DatabaseMetaData |
getMetaData()
Gets DB meta data.
|
java.lang.String |
getPassword()
Gets connection password (UI support)
|
java.lang.String |
getSchema()
Gets DB schema name.
|
java.lang.Object |
getSessionProperty(java.lang.Class<?> owner,
java.lang.String name)
Gets a session property.
|
boolean |
getSilent()
No SQL-Exceptions will be logged in silent mode.
|
protected void |
init() |
void |
insertBlob(java.lang.String table,
java.lang.String column,
java.lang.String where,
java.io.File lobFile)
Inserts a BLob.
|
void |
insertClob(java.lang.String table,
java.lang.String column,
java.lang.String where,
java.io.File lobFile,
long length)
Inserts a CLob.
|
void |
insertSQLXML(java.lang.String table,
java.lang.String column,
java.lang.String where,
java.io.File lobFile,
long length)
Inserts a SQL-XML.
|
boolean |
isConnectionExclusive() |
boolean |
isDown() |
void |
killRunningStatements()
Cancels all currently running statements.
|
void |
markConnectionAsPotentiallyInvalid(java.sql.Connection con)
Marks a connection as potentially invalid.
|
void |
reconnect()
Closes current connection and opens a new one.
|
void |
removeSessionProperties(java.lang.Class<?> owner)
Removes all session properties.
|
static void |
resetGlobalFallbackConnection() |
void |
rollbackAll()
Rolls back and closes all connections.
|
void |
setCliArguments(java.util.List<java.lang.String> args)
Sets CLI connection arguments (UI support)
|
protected void |
setConnection(java.sql.Connection con) |
void |
setGlobalFallbackConnection() |
void |
setIntrospectionSchema(java.lang.String introspectionSchema)
Sets optional schema for database analysis.
|
void |
setLogPrefix(java.lang.String logPrefix) |
void |
setLogStatements(boolean logStatements)
Log statements?
|
void |
setPassword(java.lang.String password)
Sets connection password (UI support)
|
void |
setSessionProperty(java.lang.Class<?> owner,
java.lang.String name,
java.lang.Object property)
Sets a session property.
|
void |
setSilent(boolean silent)
No SQL-Exceptions will be logged in silent mode.
|
static void |
setThreadSharesConnection() |
void |
shutDown()
Closes all connections.
|
protected java.lang.ThreadLocal<java.sql.Connection> connection
public final WorkingTableScope scope
public static final Logger _log
protected final Session.ConnectionFactory connectionFactory
public final DBMS dbms
public final java.lang.String driverClassName
public final java.lang.String dbUrl
null
if unknown)protected java.util.concurrent.atomic.AtomicBoolean down
public final java.lang.Object MD_GETCOLUMNS_LOCK
public static volatile long lastUpdateTS
public Session(javax.sql.DataSource dataSource, DBMS dbms, java.lang.Integer isolationLevel) throws java.sql.SQLException
dataSource
- the data sourcedbms
- the DBMSjava.sql.SQLException
public Session(javax.sql.DataSource dataSource, DBMS dbms, java.lang.Integer isolationLevel, WorkingTableScope scope, boolean transactional) throws java.sql.SQLException
dataSource
- the data sourcedbms
- the DBMSjava.sql.SQLException
public Session(javax.sql.DataSource dataSource, DBMS dbms, java.lang.Integer isolationLevel, WorkingTableScope scope, boolean transactional, boolean local) throws java.sql.SQLException
dataSource
- the data sourcedbms
- the DBMSlocal
- true
for the local entity-graph databasejava.sql.SQLException
protected void setConnection(java.sql.Connection con)
public void markConnectionAsPotentiallyInvalid(java.sql.Connection con)
getConnection()
.con
- the connectionprotected void init() throws java.sql.SQLException
java.sql.SQLException
public void reconnect()
public void setSilent(boolean silent)
silent
- true
for silencepublic boolean getSilent()
true
for silencepublic void setLogStatements(boolean logStatements)
public boolean getLogStatements()
public java.lang.String getSchema()
public long executeQuery(java.lang.String sqlQuery, Session.ResultSetReader reader, boolean withExplicitCommit) throws java.sql.SQLException
sqlQuery
- the query in SQLreader
- the reader for the resultwithExplicitCommit
- if true
, switch of autocommit and commit explicitlyjava.sql.SQLException
public long executeQuery(java.lang.String sqlQuery, Session.ResultSetReader reader) throws java.sql.SQLException
sqlQuery
- the query in SQLreader
- the reader for the resultjava.sql.SQLException
public long executeQuery(java.lang.String sqlQuery, Session.ResultSetReader reader, java.lang.String alternativeSQL, java.lang.Object context, long limit, boolean withExplicitCommit) throws java.sql.SQLException
sqlQuery
- the query in SQLreader
- the reader for the resultalternativeSQL
- query to be executed if sqlQuery failscontext
- cancellation contextlimit
- row limit, 0 for unlimitedwithExplicitCommit
- if true
, switch of autocommit and commit explicitlyjava.sql.SQLException
public long executeQuery(java.lang.String sqlQuery, Session.ResultSetReader reader, java.lang.String alternativeSQL, java.lang.Object context, long limit) throws java.sql.SQLException
sqlQuery
- the query in SQLreader
- the reader for the resultalternativeSQL
- query to be executed if sqlQuery failscontext
- cancellation contextlimit
- row limit, 0 for unlimitedjava.sql.SQLException
public long executeQuery(java.lang.String sqlQuery, Session.ResultSetReader reader, java.lang.String alternativeSQL, java.lang.Object context, long limit, int timeout, boolean withExplicitCommit) throws java.sql.SQLException
sqlQuery
- the query in SQLreader
- the reader for the resultalternativeSQL
- query to be executed if sqlQuery failslimit
- row limit, 0 for unlimitedcontext
- cancellation contexttimeout
- the timeout in secwithExplicitCommit
- if true
, switch of autocommit and commit explicitlyjava.sql.SQLException
public void executeQuery(java.io.File sqlFile, Session.ResultSetReader reader, boolean withExplicitCommit) throws java.sql.SQLException
sqlFile
- file containing a query in SQLreader
- the reader for the resultwithExplicitCommit
- if true
, switch of autocommit and commit explicitlyjava.sql.SQLException
public int executeUpdate(java.lang.String sqlUpdate) throws java.sql.SQLException
sqlUpdate
- the update in SQLjava.sql.SQLException
public int executeUpdate(java.lang.String sqlUpdate, java.lang.Object[] parameter) throws java.sql.SQLException
sqlUpdate
- the update in SQLparameter
- the parametersjava.sql.SQLException
public void insertClob(java.lang.String table, java.lang.String column, java.lang.String where, java.io.File lobFile, long length) throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
public void insertSQLXML(java.lang.String table, java.lang.String column, java.lang.String where, java.io.File lobFile, long length) throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
public void insertBlob(java.lang.String table, java.lang.String column, java.lang.String where, java.io.File lobFile) throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
public long execute(java.lang.String sql) throws java.sql.SQLException
sql
- the SQL-Statementjava.sql.SQLException
public long execute(java.lang.String sql, java.lang.Object cancellationContext, boolean acceptQueries) throws java.sql.SQLException
sql
- the SQL-Statementjava.sql.SQLException
public void disableMetaDataChecking()
public java.sql.DatabaseMetaData getMetaData() throws java.sql.SQLException
java.sql.SQLException
public void shutDown()
public boolean isDown()
public void killRunningStatements()
public void rollbackAll() throws java.sql.SQLException
java.sql.SQLException
public void commitAll() throws java.sql.SQLException
java.sql.SQLException
public java.lang.String getIntrospectionSchema()
public void setIntrospectionSchema(java.lang.String introspectionSchema)
introspectionSchema
- optional schema for database analysispublic java.lang.String getPassword()
public void setPassword(java.lang.String password)
public void setCliArguments(java.util.List<java.lang.String> args)
public java.util.List<java.lang.String> getCliArguments()
public java.sql.Connection getConnection() throws java.sql.SQLException
java.sql.SQLException
public java.sql.Connection createNewConnection() throws java.sql.SQLException
java.sql.SQLException
public InlineViewStyle getInlineViewStyle()
InlineViewStyle
for this session.InlineViewStyle
for this session or null
, if no style is foundpublic void setSessionProperty(java.lang.Class<?> owner, java.lang.String name, java.lang.Object property)
owner
- the class that owns the propertyname
- name of the propertyproperty
- value of the propertypublic java.lang.Object getSessionProperty(java.lang.Class<?> owner, java.lang.String name)
owner
- the class that owns the propertyname
- name of the propertypublic void removeSessionProperties(java.lang.Class<?> owner)
owner
- the class that owns the propertiespublic boolean checkQuery(java.lang.String sql)
sql
- true
iff sql is executable without errorspublic static void setThreadSharesConnection()
public void setLogPrefix(java.lang.String logPrefix)
public void setGlobalFallbackConnection()
public static void resetGlobalFallbackConnection()
public boolean isConnectionExclusive()
public java.lang.String getConnectionStats()