public class DataAccess extends Object
Users, PublicKeys, Containers and Accesses tables.| Modifier and Type | Field and Description | 
|---|---|
| static String | DATABASE_LOCATION_SEED_SUFFIX | 
| Constructor and Description | 
|---|
| DataAccess(String location,
          String hexEncodedAes256Key)Constructor with the  DatabaseWrapper's location and hexEncodedAes256Key. | 
| DataAccess(String location,
          String hexEncodedAes256Key,
          int version)Constructor with the  DatabaseWrapper's location, hexEncodedAes256Key and version. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | closeDatabase()If the database is open this will close the JDBC  Connection. | 
| Statement | createStatement()Creates a  Statementusing the JDBCConnection. | 
| void | destroyDatabase()This will close the JDBC  Connectionand then delete the database file. | 
| long | executeCountQueryWithParameters(ParameterizedSql parameterizedSql)This will execute the count query with the given parameters and return the result. | 
| int | executeUpdateWithParameters(ParameterizedSql parameterizedSql)The will execute the given sql as an update with the given parameters (insert, update, delete, etc). | 
| int | getVersion()Get the version of the database. | 
| DatabaseOpenState | openOrCreateDatabase()This will open or create the database. | 
| PreparedStatement | prepareStatement(ParameterizedSql parameterizedSql)Create a  PreparedStatementfor the given sql and fill the parameters. | 
public static final String DATABASE_LOCATION_SEED_SUFFIX
public DataAccess(String location, String hexEncodedAes256Key)
DatabaseWrapper's location and hexEncodedAes256Key.  This will set the version of
 the database to CURRENT_VERSION.location - the file location of the DatabaseWrapperhexEncodedAes256Key - the hex encoded AES 256 key of the DatabaseWrapperpublic DataAccess(String location, String hexEncodedAes256Key, int version)
DatabaseWrapper's location, hexEncodedAes256Key and version.location - the file location of the DatabaseWrapperhexEncodedAes256Key - the hex encoded AES 256 key of the DatabaseWrapperversion - the version of the databasepublic void closeDatabase()
                   throws SQLException
Connection.SQLException - thrown if there was an issue closing the Connectionpublic Statement createStatement() throws SQLException
Statement using the JDBC Connection.
 NOTE: the database must be open before you call this method.
StatementSQLException - thrown if there was an issue creating the Statementpublic void destroyDatabase()
                     throws IOException,
                            SQLException
Connection and then delete the database file.
 NOTE: the database file will be deleted and cannot be recovered!
IOException - thrown if there was an issue deleting the database fileSQLException - thrown if there was an issue closing the Connectionpublic long executeCountQueryWithParameters(ParameterizedSql parameterizedSql) throws SQLException
NOTE: the database must be open before you call this method.
parameterizedSql - the count query to run and the parameters for the querySQLException - thrown if there was an issue executing the count querypublic int executeUpdateWithParameters(ParameterizedSql parameterizedSql) throws SQLException
NOTE: the database must be open before you call this method.
parameterizedSql - the update sql to execute and the parameters to use in the executionSQLException - thrown if there is an issue executing the updatepublic int getVersion()
public DatabaseOpenState openOrCreateDatabase() throws IOException, SQLException
IOException - thrown if there was an issue with the database locationSQLException - thrown if there was an issue creating or opening the databasepublic PreparedStatement prepareStatement(ParameterizedSql parameterizedSql) throws SQLException
PreparedStatement for the given sql and fill the parameters.
 NOTE: the database must be open before you call this method.
parameterizedSql - the sql to create a PreparedStatement with and the parameters to fill the
                         statement withPreparedStatementSQLException - thrown if there was an issue creating the PreparedStatementCopyright © 2021. All rights reserved.