diff --git a/src/org/kar/archidata/db/DbIo.java b/src/org/kar/archidata/db/DbIo.java index 66412c4..8a53b61 100644 --- a/src/org/kar/archidata/db/DbIo.java +++ b/src/org/kar/archidata/db/DbIo.java @@ -24,47 +24,45 @@ public abstract class DbIo implements Closeable { @Override public synchronized final void close() throws IOException { - LOGGER.error("[{}] >>>>>>>>>>> Request close count={}", this.id, this.count); + LOGGER.trace("[{}] Request close count={}", this.id, this.count); if (this.count <= 0) { - LOGGER.error("[{}] >>>>>>>>>>> Request one more close: {}", this.id, this.getClass().getCanonicalName()); + LOGGER.error("[{}] Request one more close", this.id); return; } this.count--; if (this.count == 0) { - LOGGER.warn("v>>>>>>>>>>> close: {}", this.id, this.getClass().getCanonicalName()); + LOGGER.trace("[{}] close", this.id); closeImplement(); } else { - LOGGER.debug("v>>>>>>>>>>> postponed close: {}", this.id, this.getClass().getCanonicalName()); + LOGGER.trace("[{}] postponed close", this.id); } } public synchronized final void closeForce() throws IOException { - LOGGER.warn("[{}] >>>>>>>>>>> Request Force close count={}", this.id, this.count); + LOGGER.trace("[{}] Request Force close count={}", this.id, this.count); if (this.count == 0) { - LOGGER.info("[{}] >>>>>>>>>>> Nothing to do in force close, DB is already closed", this.id); + LOGGER.trace("[{}] Nothing to do in force close, DB is already closed", this.id); return; } if (this.config.getKeepConnected()) { if (this.count >= 2) { - LOGGER.error("[{}] >>>>>>>>>>> force close: {} with {} connection on it", this.id, - this.getClass().getCanonicalName(), this.count - 1); + LOGGER.error("[{}] Force close: with {} connection on it", this.id, this.count - 1); } } else if (this.count >= 1) { - LOGGER.error("[{}] >>>>>>>>>>> force close: {} with {} connection on it", this.id, - this.getClass().getCanonicalName(), this.count); + LOGGER.error("[{}] Force close: with {} connection on it", this.id, this.count); } this.count = 0; - LOGGER.warn("[{}] >>>>>>>>>>> force close: {}", this.id, this.getClass().getCanonicalName()); + LOGGER.trace("[{}] Force close", this.id); closeImplement(); } public synchronized final void open() throws IOException { - LOGGER.warn("[{}] >>>>>>>>>>> Request open count={}", this.id, this.count); + LOGGER.trace("[{}] Request open count={}", this.id, this.count); if (this.count == 0) { - LOGGER.warn("[{}] >>>>>>>>>>> open: {}", this.id, this.getClass().getCanonicalName()); + LOGGER.trace("[{}] open", this.id); openImplement(); } else { - LOGGER.debug("[{}] >>>>>>>>>>> already open: {}", this.id, this.getClass().getCanonicalName()); + LOGGER.trace("[{}] open: already done", this.id); } this.count++; diff --git a/src/org/kar/archidata/db/DbIoFactory.java b/src/org/kar/archidata/db/DbIoFactory.java index a455703..12841c7 100644 --- a/src/org/kar/archidata/db/DbIoFactory.java +++ b/src/org/kar/archidata/db/DbIoFactory.java @@ -34,7 +34,6 @@ public class DbIoFactory { dbIo.open(); dbIoStored.add(dbIo); } - dbIo.open(); return dbIo; } diff --git a/src/org/kar/archidata/db/DbIoSql.java b/src/org/kar/archidata/db/DbIoSql.java index 09570e3..f5fa030 100644 --- a/src/org/kar/archidata/db/DbIoSql.java +++ b/src/org/kar/archidata/db/DbIoSql.java @@ -11,18 +11,17 @@ import org.slf4j.LoggerFactory; public class DbIoSql extends DbIo { final static Logger LOGGER = LoggerFactory.getLogger(DbIoSql.class); - private Connection con = null; + private Connection connection = null; public DbIoSql(final DbConfig config) throws IOException { super(config); } public Connection getConnection() { - if (this.con == null) { - LOGGER.error("[{}] >>>>>>>>>> Retrieve a closed connection !!!", this.id); + if (this.connection == null) { + LOGGER.error("[{}] Retrieve a closed connection !!!", this.id); } - LOGGER.error("[{}] ++++++++++ Retrieve connection {}", this.id, this.con); - return this.con; + return this.connection; } @Override @@ -30,30 +29,26 @@ public class DbIoSql extends DbIo { final String dbUrl = this.config.getUrl(); final String login = this.config.getLogin(); final String password = this.config.getPassword(); - LOGGER.error("[{}] >>>>>>>>>> openImplement ", this.id); try { - this.con = DriverManager.getConnection(dbUrl, login, password); - LOGGER.error("[{}] >>>>>>>>>> openImplement ==> {}", this.id, this.con); + this.connection = DriverManager.getConnection(dbUrl, login, password); } catch (final SQLException ex) { LOGGER.error("Connection db fail: " + ex.getMessage() + " On URL: " + dbUrl); throw new IOException("Connection db fail: " + ex.getMessage() + " On URL: " + dbUrl); } - if (this.con == null) { - LOGGER.error("Request open of un-open connection !!!"); - return; + if (this.connection == null) { + throw new IOException("Connection db fail: NULL On URL: " + dbUrl); } } @Override synchronized public void closeImplement() throws IOException { - LOGGER.error("[{}] >>>>>>>>>> closeImplement ", this.id); - if (this.con == null) { + if (this.connection == null) { LOGGER.error("Request close of un-open connection !!!"); return; } try { - this.con.close(); - this.con = null; + this.connection.close(); + this.connection = null; } catch (final SQLException ex) { throw new IOException("Dis-connection db fail: " + ex.getMessage()); }