mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-13 02:35:52 +00:00
Add ctor that takes a connectionUrl instead of hostname and database name.
Avoid exception in close() - only rollback when autocommit is false.
This commit is contained in:
parent
417c81f54d
commit
c95a864831
@ -107,9 +107,24 @@ public class PostgresFullPrunedBlockStore implements FullPrunedBlockStore {
|
|||||||
*/
|
*/
|
||||||
public PostgresFullPrunedBlockStore(NetworkParameters params, int fullStoreDepth, String hostname, String dbName,
|
public PostgresFullPrunedBlockStore(NetworkParameters params, int fullStoreDepth, String hostname, String dbName,
|
||||||
String username, String password) throws BlockStoreException {
|
String username, String password) throws BlockStoreException {
|
||||||
|
this(params, fullStoreDepth, "jdbc:postgresql://" + hostname + "/" + dbName, username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new PostgresFullPrunedBlockStore.
|
||||||
|
*
|
||||||
|
* @param params A copy of the NetworkParameters used
|
||||||
|
* @param fullStoreDepth The number of blocks of history stored in full (something like 1000 is pretty safe)
|
||||||
|
* @param connectionURL The jdbc url to connect to the database.
|
||||||
|
* @param username The database username
|
||||||
|
* @param password The password to the database
|
||||||
|
* @throws BlockStoreException if the database fails to open for any reason
|
||||||
|
*/
|
||||||
|
public PostgresFullPrunedBlockStore(NetworkParameters params, int fullStoreDepth, String connectionURL,
|
||||||
|
String username, String password) throws BlockStoreException {
|
||||||
this.params = params;
|
this.params = params;
|
||||||
this.fullStoreDepth = fullStoreDepth;
|
this.fullStoreDepth = fullStoreDepth;
|
||||||
connectionURL = "jdbc:postgresql://" + hostname + "/" + dbName;
|
this.connectionURL = connectionURL;
|
||||||
|
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
@ -160,7 +175,9 @@ public class PostgresFullPrunedBlockStore implements FullPrunedBlockStore {
|
|||||||
public synchronized void close() {
|
public synchronized void close() {
|
||||||
for (Connection conn : allConnections) {
|
for (Connection conn : allConnections) {
|
||||||
try {
|
try {
|
||||||
|
if(!conn.getAutoCommit()) {
|
||||||
conn.rollback();
|
conn.rollback();
|
||||||
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user