Class InsertAndGetID
java.lang.Object
com.github.tadukoo.database.mysql.transaction.InsertAndGetID
- All Implemented Interfaces:
SQLTransaction<Integer>
Insert and Get ID is a
SQLTransaction that will run an insert statement on a table and then
retrieve the id of the new entry.- Version:
- Alpha v.0.3
- Author:
- Logan Ferree (Tadukoo)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic InsertAndGetIDcreateInsertAndGetID(String table, String idColumnName, Collection<String> cols, Collection<Object> values) Creates a newInsertAndGetIDusing the given information.execute(Connection conn, com.github.tadukoo.util.logger.EasyLogger logger) Executes the transaction using the given connection, and will log messages as needed to the givenEasyLoggerabstract Stringabstract StringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.github.tadukoo.database.mysql.transaction.SQLTransaction
getTransactionName
-
Constructor Details
-
InsertAndGetID
public InsertAndGetID()
-
-
Method Details
-
getInsertString
- Returns:
- The string to report when the insert is run (can be blank for no reporting)
-
getInsertSQL
- Returns:
- The MySQL string to use for the insert statement
-
getSelectString
- Returns:
- The string to report when the id retrieval is run (can be blank for no reporting)
-
getSelectSQL
- Returns:
- The MySQL string to use for retrieving the id from the table
-
execute
public Integer execute(Connection conn, com.github.tadukoo.util.logger.EasyLogger logger) throws SQLException Executes the transaction using the given connection, and will log messages as needed to the givenEasyLogger- Specified by:
executein interfaceSQLTransaction<Integer>- Parameters:
conn- TheConnectionto use for the transactionlogger- TheEasyLoggerto use for logging messages as needed- Returns:
- The result of the transaction
- Throws:
SQLException- If anything goes wrong
-
createInsertAndGetID
public static InsertAndGetID createInsertAndGetID(String table, String idColumnName, Collection<String> cols, Collection<Object> values) Creates a newInsertAndGetIDusing the given information.- Parameters:
table- The table to use for the insert and id retrievalidColumnName- The name of the id column in the tablecols- The columns of the table to use in the insertvalues- The values to use for the insert (should be in the same order as the cols)- Returns:
- An
InsertAndGetIDobject to use for a transaction
-