[jboss-svn-commits] JBL Code SVN: r6165 - labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/persist

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Sep 11 19:44:48 EDT 2006


Author: mohit309
Date: 2006-09-11 19:44:47 -0400 (Mon, 11 Sep 2006)
New Revision: 6165

Modified:
   labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/persist/JdbcCleanConn.java
Log:
Changed from Exception to SQLException

Modified: labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/persist/JdbcCleanConn.java
===================================================================
--- labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/persist/JdbcCleanConn.java	2006-09-11 23:03:16 UTC (rev 6164)
+++ labs/jbossesb/branches/refactor/product/core/common/src/org/jboss/soa/esb/helpers/persist/JdbcCleanConn.java	2006-09-11 23:44:47 UTC (rev 6165)
@@ -25,6 +25,7 @@
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
+import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -39,21 +40,25 @@
 
 	protected List<PreparedStatement> m_olPrepSt = new ArrayList<PreparedStatement>();
 
-	protected Logger m_oLogger;
+	private static Logger m_oLogger = Logger.getLogger(JdbcCleanConn.class);
 
-	public JdbcCleanConn(DataSource p_oDS) throws Exception {
+	public JdbcCleanConn(DataSource p_oDS){
 		m_oDS = p_oDS;
 		m_oLogger = Logger.getLogger(this.getClass());
 	}
 
-	public void commit() throws Exception {
+	public void commit() throws SQLException {
 		if (null != m_conn)
 			m_conn.commit();
+		else
+			throw new SQLException("Connection closed");
 	}
 
-	public void rollback() throws Exception {
+	public void rollback() throws SQLException {
 		if (null != m_conn)
 			m_conn.rollback();
+		else 
+			throw new SQLException("Connection closed");
 	}
 
 	public void release() {
@@ -61,16 +66,19 @@
 			try {
 				m_conn.rollback();
 			} catch (Exception eRoll) {
+				m_oLogger.error("release: Connection Rollback problem",eRoll);
 			}
 
 			for (PreparedStatement PS : m_olPrepSt)
 				try {
 					PS.close();
 				} catch (Exception e) {
+					m_oLogger.error("release: PreparedStatement Close",e);
 				}
 			try {
 				m_conn.close();
 			} catch (Exception e1) {
+				m_oLogger.error("release: Connection Close problem",e1);
 			}
 		}
 		m_olPrepSt.clear();
@@ -78,7 +86,7 @@
 	} // __________________________________
 
 	public PreparedStatement prepareStatement(String p_sSt, int p_i1, int p_i2)
-			throws Exception {
+			throws SQLException {
 		if (null == m_conn)
 			connect();
 		PreparedStatement PS = m_conn.prepareStatement(p_sSt, p_i1, p_i2);
@@ -86,7 +94,7 @@
 		return PS;
 	} // __________________________________
 
-	public PreparedStatement prepareStatement(String p_sSt) throws Exception {
+	public PreparedStatement prepareStatement(String p_sSt) throws SQLException {
 		if (null == m_conn)
 			connect();
 		PreparedStatement PS = m_conn.prepareStatement(p_sSt);
@@ -95,7 +103,7 @@
 	} // __________________________________
 
 	public ResultSet execQueryWait(PreparedStatement p_PS, int p_iQtry)
-			throws Exception {
+			throws SQLException {
 		Exception eRet = null;
 		int iQtry = (p_iQtry < 1) ? 1 : (p_iQtry < 50) ? p_iQtry : 50;
 		for (int i1 = 0; i1 < iQtry; i1++) {
@@ -105,16 +113,21 @@
 				if (null == eRet)
 					eRet = new Exception(e.getMessage());
 				// System.out.println("Retrying "+i1);
-				Thread.sleep(100 + (new Double(100 * Math.random()))
-						.longValue());
+				try {
+					Thread.sleep(100 + (new Double(100 * Math.random())).longValue());
+				} catch (InterruptedException e1) {
+					m_oLogger.error("execQueryWait: Interrupted Exception",e);
+				}
 			}
 		}
 		m_oLogger.error("execQueryWait() FAILED", eRet);
-		throw eRet;
+		SQLException excep = new SQLException();
+		excep.setStackTrace(eRet.getStackTrace());
+		throw excep;
 	} // __________________________________
 
 	public void execUpdWait(PreparedStatement p_PS, int p_iQtry)
-			throws Exception {
+			throws SQLException {
 		Exception eRet = null;
 		int iQtry = (p_iQtry < 1) ? 1 : (p_iQtry < 50) ? p_iQtry : 50;
 		for (int i1 = 0; i1 < iQtry; i1++) {
@@ -125,15 +138,20 @@
 				if (null == eRet)
 					eRet = e;
 				// System.out.println("Retrying "+i1);
-				Thread.sleep(100 + (new Double(100 * Math.random()))
-						.longValue());
+				try {
+					Thread.sleep(100 + (new Double(100 * Math.random())).longValue());
+				} catch (InterruptedException e1) {
+					m_oLogger.error("execUpdWait: Interrupted Exception",e);
+				}
 			}
 		}
 		m_oLogger.error("execUpdWait() FAILED", eRet);
-		throw eRet;
+		SQLException excep = new SQLException();
+		excep.setStackTrace(eRet.getStackTrace());
+		throw excep;
 	} // __________________________________
 
-	private void connect() throws Exception {
+	private void connect() throws SQLException {
 		Exception eRet = null;
 		for (int i1 = 0; i1 < 5; i1++) {
 			try {
@@ -143,14 +161,19 @@
 			} catch (Exception e) {
 				if (null == eRet)
 					eRet = e;
-				System.out.println("Connecting " + i1);
-				Thread.sleep(2000 + (new Double(100 * Math.random()))
-						.longValue());
+				m_oLogger.debug("Connecting " + i1);
+				try {
+					Thread.sleep(2000 + (new Double(100 * Math.random())).longValue());
+				} catch (InterruptedException e1) {
+					m_oLogger.error("connect: Interrupted Exception",e);
+				}
 			}
 		}
 		if (null != eRet) {
 			m_oLogger.error("connect() FAILED", eRet);
-			throw eRet;
+			SQLException excep = new SQLException();
+			excep.setStackTrace(eRet.getStackTrace());
+			throw excep;
 		}
 		m_conn.setAutoCommit(false);
 		m_conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);




More information about the jboss-svn-commits mailing list