* Connects to the DB (so many connections as configured)
* @param disconnectFirst if 'true' then all connections to the db are closed before reconnecting.
*/
private void connect(boolean disconnectFirst, boolean doLog) throws SQLException {
int oldStatus;
I_StorageProblemListener lst = null;
synchronized(this) {
if (disconnectFirst) disconnect();
for (int i = 0; i < this.capacity; i++) {
if (log.isLoggable(Level.FINE)) log.fine("initializing DB connection "+ i + " url=" + url + " user=" + user); // + " password=" + password);
//Logging since JDK 1.3:
//java.io.OutputStream buf = new java.io.ByteArrayOutputStream();
//java.io.PrintStream pr = new java.io.PrintStream(buf);
//DriverManager.setLogStream(pr);
addConnectionToPool((i==0)&&doLog);
if (log.isLoggable(Level.FINE))
log.fine("initialized DB connection "+ i + " success");
}
oldStatus = this.status;
this.status = I_StorageProblemListener.AVAILABLE;
lst = this.storageProblemListener;
}
this.isShutdown = false;
if (lst != null) lst.storageAvailable(oldStatus);
log.info("Successfully reconnected to database");
}