[cvs] expresso commit by rauld: Yves Henri Amaizo's contribution from

JCorporate Ltd jcorp at jcorporate.com
Mon Dec 27 12:57:58 UTC 2004


Log Message:
-----------
Yves Henri Amaizo's contribution from 20041204

Modified Files:
--------------
    expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/db:
        TableCreator.java

Revision Data
-------------
Index: TableCreator.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/db/TableCreator.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/db/TableCreator.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/db/TableCreator.java -u -r1.20 -r1.21
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/db/TableCreator.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/db/TableCreator.java
@@ -566,4 +566,60 @@
 
     }
 
+	/**
+	 * Delete Table - Deletes a table from the specified db
+	 *
+     *
+     * @param   dbObj The Instantiated Database Object to check against.
+     * @throws    DBException If there's an error creating the table with the
+     * database
+     * @todo Refactor this method into smaller chunks... ie creating the table.
+     * Creating
+     *
+     * Create by Yves Henri AMAIZO <amy_amaizo at compuserve.com>
+     * @since $DatabaseSchema  $Date$
+	 */
+	public  void deleTable(DBObject dbObj)
+			throws DBException {
+
+		FastStringBuffer sqlStatement = FastStringBuffer.getInstance();
+
+		JDBCObjectMetaData metadata = dbObj.getJDBCMetaData();
+
+		try {
+
+			DBConnectionPool myPool = null;
+			DBConnection myConnection = null;
+			boolean addComma = false;
+
+			try {
+
+				myPool = DBConnectionPool.getInstance(dbObj.getDataContext());
+				myConnection = myPool.getConnection("Table Deletor");
+
+				sqlStatement = sqlStatement.append("DROP TABLE ");
+				sqlStatement.append(metadata.getTargetSQLTable(dbObj.getDataContext()));
+
+
+				// Send SQL to database
+				if (log.isInfoEnabled()) {
+					log.info("Executing:" + sqlStatement.toString());
+				}
+				myConnection.executeUpdate(sqlStatement.toString());
+
+
+			} catch (Throwable t) {
+				t.printStackTrace();
+				throw new DBException(t);
+			} finally {
+				if (myPool != null) {
+					myPool.release(myConnection);
+				}
+			}
+		} finally {
+			sqlStatement.release();
+		}
+
+	}
+
 }


More information about the cvs mailing list