public class ExtensionHikariConnectionContext extends Object implements AutoCloseable
Do not remove this header!
Version 1.0
MIT License
Copyright (c) 2017
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
| Modifier and Type | Class and Description |
|---|---|
static interface |
ExtensionHikariConnectionContext.SQlRetriever |
| Modifier and Type | Field and Description |
|---|---|
static String |
MYSQL_DRIVER |
static String |
SQLITE_DRIVER |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the database context
|
boolean |
execute(String sql,
Connection connection,
Object... parameters)
Executes a preparedStatement and sets the given parameters to the statement
|
int |
executeInsert(String sql,
Connection connection,
Object... parameters)
Executes a preparedStatement and sets the given parameters to the statement
|
PreparedStatement |
executeQuery(String sql,
Connection connection,
Object... parameters)
Executes a preparedStatement and sets the given parameters to the statement
|
boolean |
executeStored(String fileName,
Connection connection,
Object... parameters)
Reads a sqlStatement from the given fileName, executes it and sets the given parameter
|
int |
executeStoredInsert(String fileName,
Connection connection,
Object... parameters)
Reads a sqlStatement from the given fileName, executes it and sets the given parameter
|
PreparedStatement |
executeStoredQuery(String fileName,
Connection connection,
Object... parameters)
Reads a sqlStatement from the given fileName, executes it and sets the given parameter
|
int |
executeStoredUpdate(String fileName,
Connection connection,
Object... parameters)
Reads a sqlStatement from the given fileName, executes it and sets the given parameter
|
int |
executeUpdate(String sql,
Connection connection,
Object... parameters)
Executes a preparedStatement and sets the given parameters to the statement
|
static ExtensionHikariConnectionContext |
from(String driver,
String url,
ExtensionHikariConnectionContext.SQlRetriever retriever)
Opens a new DatabaseContext for the given url
|
static ExtensionHikariConnectionContext |
from(String driver,
String urlPrefix,
String ip,
int port,
String database,
String userName,
String password,
ExtensionHikariConnectionContext.SQlRetriever retriever)
Opens a new DatabaseContext for the given ip, port, database, username and password
|
Connection |
getConnection()
Provides an connection to the database which has to be closed after being used
|
String |
getStringFromFile(String statementName)
Manages caching of statements
|
public static final String SQLITE_DRIVER
public static final String MYSQL_DRIVER
public Connection getConnection() throws SQLException
SQLException - exceptionpublic boolean executeStored(String fileName, Connection connection, Object... parameters) throws SQLException
fileName - fileNameconnection - connectionparameters - parametersSQLException - exceptionpublic boolean execute(String sql, Connection connection, Object... parameters) throws SQLException
sql - sqlconnection - connectionparameters - parametersSQLException - exceptionpublic PreparedStatement executeStoredQuery(String fileName, Connection connection, Object... parameters) throws SQLException
fileName - fileNameconnection - connectionparameters - parametersSQLException - exceptionpublic PreparedStatement executeQuery(String sql, Connection connection, Object... parameters) throws SQLException
sql - sqlconnection - connectionparameters - parametersSQLException - exceptionpublic int executeStoredUpdate(String fileName, Connection connection, Object... parameters) throws SQLException
fileName - fileNameconnection - connectionparameters - parametersSQLException - exceptionpublic int executeUpdate(String sql, Connection connection, Object... parameters) throws SQLException
sql - sqlconnection - connectionparameters - parametersSQLException - exceptionpublic int executeStoredInsert(String fileName, Connection connection, Object... parameters) throws SQLException
fileName - fileNameconnection - connectionparameters - parametersSQLException - exceptionpublic int executeInsert(String sql, Connection connection, Object... parameters) throws SQLException
sql - sqlconnection - connectionparameters - parametersSQLException - exceptionpublic void close()
close in interface AutoCloseablepublic String getStringFromFile(String statementName)
statementName - statementNamepublic static ExtensionHikariConnectionContext from(String driver, String url, ExtensionHikariConnectionContext.SQlRetriever retriever) throws IOException
driver - driverurl - urlretriever - retrieverIOException - exceptionpublic static ExtensionHikariConnectionContext from(String driver, String urlPrefix, String ip, int port, String database, String userName, String password, ExtensionHikariConnectionContext.SQlRetriever retriever) throws IOException
driver - driverip - ipport - porturlPrefix - prefixdatabase - databaseuserName - userNamepassword - passwordretriever - retrieverIOException - exceptionCopyright © 2017. All rights reserved.