public final class HarvestDBConnection extends Object
The statements to create the tables are located in:
The implementation relies on a connection pool. Once acquired through the get() method, a connection must be explicitly returned to the pool by calling the release(Connection) method.
THis class is intended to be used statically, and hence cannot be instantiated and is final.
Modifier and Type | Method and Description |
---|---|
static void |
cleanup()
Closes the underlying data source.
|
static void |
executeSql(Connection conn,
String dbm,
String tableName,
int version)
Look for the file sql-migration/${dbm}/${tableName}.${version}.sql inside in the harvester-core.jar file.
|
static void |
executeSql(String dbm,
String tableName,
int version)
Execute the sql to update a given table to a given version.
|
static Connection |
get()
Get a connection to the harvest definition database from the pool.
|
static String |
getDBUrl()
Method for retrieving the url for the harvest definition database.
|
static void |
release(Connection connection)
Helper method to return a connection to the pool.
|
static void |
updateTable(Connection c,
String table,
int newVersion,
String... updates) |
protected static void |
updateTable(String table,
int newVersion,
String... updates)
Update a table by executing all the statements in the updates String array.
|
static void |
updateTableVersion(Connection c,
String table,
int newVersion) |
protected static void |
updateTableVersion(String table,
int newVersion,
String... updates) |
public static Connection get()
CommonSettings.DB_POOL_MIN_SIZE
CommonSettings.DB_POOL_MAX_SIZE
CommonSettings.DB_POOL_ACQ_INC
release(Connection)
.IOFailure
- if we cannot connect to the database (or find the driver).protected static void updateTable(String table, int newVersion, String... updates)
table
- The table to updatenewVersion
- The version that the table should end up atupdates
- The SQL update statements that makes the necessary updates.IOFailure
- in case of problems in interacting with the databasepublic static void updateTable(Connection c, String table, int newVersion, String... updates)
protected static void updateTableVersion(String table, int newVersion, String... updates)
public static void updateTableVersion(Connection c, String table, int newVersion)
public static String getDBUrl()
public static void cleanup()
public static void release(Connection connection)
connection
- a connectionpublic static void executeSql(String dbm, String tableName, int version)
dbm
- the type of DBMS (mysql, postgresql,derby)tableName
- The given table to updateversion
- The table version to update topublic static void executeSql(Connection conn, String dbm, String tableName, int version)
conn
- a valid database connectiondbm
- the name of the DBMS usedtableName
- the name of the table being updatedversion
- The new version of the tableCopyright © 2005–2016 The Royal Danish Library, the Danish State and University Library, the National Library of France and the Austrian National Library.. All rights reserved.