Package org.sqlproc.engine.jdbc
Class JdbcSimpleSession
java.lang.Object
org.sqlproc.engine.jdbc.JdbcSimpleSession
- All Implemented Interfaces:
SqlSession
The JDBC stack implementation of the SQL Engine session contract. In fact it's a simple wrapper for the
Connection.
It's the first parameter to all primary methods in the SqlQueryEngine and SqlCrudEngine.
The primary contract is the method for the SqlQuery instance creation.
For more info please see the Tutorials.
- Author:
- Vladimir Hudec
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ConnectionThe connection to the database.private StringThe name of the database related to this session. -
Constructor Summary
ConstructorsConstructorDescriptionJdbcSimpleSession(Connection connection) Creates a new instance.JdbcSimpleSession(Connection connection, String name) Creates a new instance of this dynamic proxy. -
Method Summary
Modifier and TypeMethodDescriptioncreateSqlQuery(String queryString) Creates a new instance ofSqlQuery, which is a wrapper around the SQL query command.int[]executeBatch(String... statements) Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts.Returns the internal connection to the database.getName()The name of the database related to this session.voidsetConnection(Connection connection) Sets the internal connection to the database.
-
Field Details
-
connection
The connection to the database. It should be opened. -
name
The name of the database related to this session. It's usage is implementation specific.
-
-
Constructor Details
-
JdbcSimpleSession
Creates a new instance.- Parameters:
connection- the connection to the database
-
JdbcSimpleSession
Creates a new instance of this dynamic proxy.- Parameters:
connection- the connection to the databasename- the name of the database
-
-
Method Details
-
getConnection
Returns the internal connection to the database.- Returns:
- the connection to the database
-
setConnection
Sets the internal connection to the database.- Parameters:
connection- the connection to the database
-
createSqlQuery
Creates a new instance ofSqlQuery, which is a wrapper around the SQL query command.- Specified by:
createSqlQueryin interfaceSqlSession- Parameters:
queryString- the SQL query command- Returns:
- a new instance of a wrapper around the SQL query command
- Throws:
SqlProcessorException- in the case of any problem in ORM or JDBC stack
-
executeBatch
Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts.- Specified by:
executeBatchin interfaceSqlSession- Parameters:
statements- SQL statements to be executed in batch- Returns:
- an array of update counts containing one element for each command in the batch
- Throws:
SqlProcessorException- in the case of any problem in ORM or JDBC stack
-
getName
Description copied from interface:SqlSessionThe name of the database related to this session. It's usage is implementation specific.- Specified by:
getNamein interfaceSqlSession- Returns:
- the name of the database related to this session. It's usage is implementation specific.
-