Class AbstractDBInterface
java.lang.Object
com.inductiveautomation.ignition.gateway.localdb.AbstractDBInterface
- All Implemented Interfaces:
DBInterface
- Direct Known Subclasses:
PersistenceSession.PersistenceSessionDBInterface
Created by colby.clegg on 11/17/2015.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.inductiveautomation.ignition.gateway.localdb.DBInterface
DBInterface.Transaction
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Connection
long
Gets the next value in a sequence.long
getSeq
(String seqName, Connection connection) Like the other getSeq, but operates against a particular local db connection, which may be necessary if the sequence generation is part of a transaction.runPrepQuery
(String stmt, Object... args) Runs the given SELECT query as a prepared statement, after setting the arguments in the varargs list.runPrepQuery
(Connection con, String stmt, Object... args) int
runPrepUpdate
(String stmt, Serializable... args) Runs the given UPDATE/INSERT/DELETE query as a prepared statement, after setting the arguments in the varargs list.static int
runPrepUpdate
(Connection con, String stmt, Serializable... args) Runs the given SELECT query, and returns the results in a List of Lists of Objects.runQuery
(Connection con, String query) runScalarQuery
(String query) Runs the given query.Runs the given transaction with a new connection.int
runUpdateQuery
(String query) Runs the given update query, and returns the number of rows affected.static int
runUpdateQuery
(Connection con, String query) protected boolean
-
Constructor Details
-
AbstractDBInterface
public AbstractDBInterface()
-
-
Method Details
-
getConnection
- Specified by:
getConnection
in interfaceDBInterface
- Throws:
SQLException
-
shouldCloseConnection
protected boolean shouldCloseConnection() -
resultSetToListNatural
- Throws:
SQLException
-
getSeq
Gets the next value in a sequence.- Specified by:
getSeq
in interfaceDBInterface
- Throws:
SQLException
-
getSeq
Description copied from interface:DBInterface
Like the other getSeq, but operates against a particular local db connection, which may be necessary if the sequence generation is part of a transaction.- Specified by:
getSeq
in interfaceDBInterface
- Throws:
SQLException
-
runPrepQuery
public static List<List<Object>> runPrepQuery(Connection con, String stmt, Object... args) throws SQLException - Throws:
SQLException
-
runPrepQuery
Description copied from interface:DBInterface
Runs the given SELECT query as a prepared statement, after setting the arguments in the varargs list. Returns the results in a List of Lists of Objects.- Specified by:
runPrepQuery
in interfaceDBInterface
- Throws:
SQLException
-
runPrepUpdate
public static int runPrepUpdate(Connection con, String stmt, Serializable... args) throws SQLException - Throws:
SQLException
-
runPrepUpdate
Description copied from interface:DBInterface
Runs the given UPDATE/INSERT/DELETE query as a prepared statement, after setting the arguments in the varargs list. Returns the number of rows affected.- Specified by:
runPrepUpdate
in interfaceDBInterface
- Throws:
SQLException
-
runQuery
- Throws:
SQLException
-
runQuery
Description copied from interface:DBInterface
Runs the given SELECT query, and returns the results in a List of Lists of Objects.- Specified by:
runQuery
in interfaceDBInterface
- Throws:
SQLException
-
runScalarQuery
Runs the given query. Returns null if no rows are returned, or the value at row 1 column 1 as a string if rows are returned.- Specified by:
runScalarQuery
in interfaceDBInterface
- Throws:
SQLException
-
runTransaction
Runs the given transaction with a new connection. Closes the connection if the transaction doesn't do it.- Specified by:
runTransaction
in interfaceDBInterface
- Throws:
SQLException
-
runUpdateQuery
- Throws:
SQLException
-
runUpdateQuery
Runs the given update query, and returns the number of rows affected.- Specified by:
runUpdateQuery
in interfaceDBInterface
- Throws:
SQLException
-