Kaydet (Commit) fefc2a7c authored tarafından Kurt Zenker's avatar Kurt Zenker

INTEGRATION: CWS qadev14 (1.3.2); FILE MERGED

2003/11/28 15:14:48 sg 1.3.2.1: #114147#CHG: closed databse connection
üst 93096ca8
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: DataBaseOutProducer.java,v $ * $RCSfile: DataBaseOutProducer.java,v $
* *
* $Revision: 1.3 $ * $Revision: 1.4 $
* *
* last change:$Date: 2003-11-18 16:16:26 $ * last change:$Date: 2003-12-11 11:32:30 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -92,7 +92,12 @@ public abstract class DataBaseOutProducer implements LogWriter { ...@@ -92,7 +92,12 @@ public abstract class DataBaseOutProducer implements LogWriter {
mSqlInput = new Hashtable(); mSqlInput = new Hashtable();
mSqlInput.putAll(param); mSqlInput.putAll(param);
String debug = (String)param.get("DebugIsActive"); Object o = param.get("DebugIsActive");
String debug = null;
if (o instanceof String)
debug = (String)o;
else
debug = o.toString();
if (debug != null && (debug.equalsIgnoreCase("true") || debug.equalsIgnoreCase("yes"))) { if (debug != null && (debug.equalsIgnoreCase("true") || debug.equalsIgnoreCase("yes"))) {
m_bDebug = true; m_bDebug = true;
} }
...@@ -129,8 +134,10 @@ public abstract class DataBaseOutProducer implements LogWriter { ...@@ -129,8 +134,10 @@ public abstract class DataBaseOutProducer implements LogWriter {
* *
*/ */
public boolean summary(DescEntry entry) { public boolean summary(DescEntry entry) {
mSqlExec.openConnection();
findTypeInEntryTree(entry, entry.Logger); findTypeInEntryTree(entry, entry.Logger);
// checkDataBase(entry.Logger); // checkDataBase(entry.Logger);
mSqlExec.closeConnection();
return true; return true;
} }
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: SQLExecution.java,v $ * $RCSfile: SQLExecution.java,v $
* *
* $Revision: 1.3 $ * $Revision: 1.4 $
* *
* last change:$Date: 2003-11-18 16:16:58 $ * last change:$Date: 2003-12-11 11:32:46 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -75,11 +75,13 @@ import java.util.Vector; ...@@ -75,11 +75,13 @@ import java.util.Vector;
*/ */
public class SQLExecution { public class SQLExecution {
protected Connection mConnection = null;
protected Statement mStatement = null; protected Statement mStatement = null;
protected String mJdbcClass = null; protected String mJdbcClass = null;
protected String mDbURL = null; protected String mDbURL = null;
protected String mUser = null; protected String mUser = null;
protected String mPassword = null; protected String mPassword = null;
protected boolean m_bConnectionOpen = false;
protected boolean m_bDebug = false; protected boolean m_bDebug = false;
...@@ -116,6 +118,7 @@ public class SQLExecution { ...@@ -116,6 +118,7 @@ public class SQLExecution {
* @return True, if no error occured. * @return True, if no error occured.
*/ */
public boolean openConnection() { public boolean openConnection() {
if(m_bConnectionOpen) return true;
try { try {
Class.forName(mJdbcClass); Class.forName(mJdbcClass);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
...@@ -125,18 +128,36 @@ public class SQLExecution { ...@@ -125,18 +128,36 @@ public class SQLExecution {
try { try {
// establish database connection // establish database connection
Connection connection = DriverManager.getConnection( mConnection = DriverManager.getConnection(
mDbURL, mUser, mPassword); mDbURL, mUser, mPassword);
mStatement = connection.createStatement(); mStatement = mConnection.createStatement();
} }
catch(java.sql.SQLException e) { catch(java.sql.SQLException e) {
System.err.println("Couldn't establish a connection: " + e.getMessage()); System.err.println("Couldn't establish a connection: " + e.getMessage());
return false; return false;
} }
m_bConnectionOpen = true;
return true; return true;
} }
/**
* Close the connection to the DataBase
* @return True, if no error occured.
*/
public boolean closeConnection() {
if (!m_bConnectionOpen) return true;
try {
// close database connection
mStatement.close();
mConnection.close();
}
catch(java.sql.SQLException e) {
System.err.println("Couldn't close the connection: " + e.getMessage());
return false;
}
m_bConnectionOpen = false;
return true;
}
/** /**
* Execute an sql command. * Execute an sql command.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment