Author: arminw Date: Thu Dec 21 16:47:04 2006 New Revision: 489529 URL: http://svn.apache.org/viewvc?view=rev&rev=489529 Log: minor improvements
Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/batch/BatchConnection.java db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/batch/BatchPreparedStatement.java db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/batch/PreparedStatementInvocationHandler.java Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/batch/BatchConnection.java URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/batch/BatchConnection.java?view=diff&rev=489529&r1=489528&r2=489529 ============================================================================== --- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/batch/BatchConnection.java (original) +++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/batch/BatchConnection.java Thu Dec 21 16:47:04 2006 @@ -19,7 +19,6 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; -import java.sql.Statement; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -164,8 +163,9 @@ { // [olegnitz] for JDK 1.2 we need to list both PreparedStatement and Statement // interfaces, otherwise proxy.jar works incorrectly - stmt = (PreparedStatement) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{ - PreparedStatement.class, Statement.class, BatchPreparedStatement.class}, + stmt = (PreparedStatement) Proxy.newProxyInstance( + getClass().getClassLoader(), + new Class[]{BatchPreparedStatement.class}, new PreparedStatementInvocationHandler(this, sql, m_jcd)); _statements.put(sql, stmt); } Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/batch/BatchPreparedStatement.java URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/batch/BatchPreparedStatement.java?view=diff&rev=489529&r1=489528&r2=489529 ============================================================================== --- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/batch/BatchPreparedStatement.java (original) +++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/batch/BatchPreparedStatement.java Thu Dec 21 16:47:04 2006 @@ -18,6 +18,7 @@ import java.sql.Connection; import java.sql.SQLException; +import java.sql.PreparedStatement; /** * The interface which is used to create dynamic proxy which will also @@ -26,9 +27,8 @@ * * @author Oleg Nitz (<a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>) */ -public interface BatchPreparedStatement +public interface BatchPreparedStatement extends PreparedStatement { - /** * This method performs database modification at the very and of transaction. */ Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/batch/PreparedStatementInvocationHandler.java URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/batch/PreparedStatementInvocationHandler.java?view=diff&rev=489529&r1=489528&r2=489529 ============================================================================== --- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/batch/PreparedStatementInvocationHandler.java (original) +++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/batch/PreparedStatementInvocationHandler.java Thu Dec 21 16:47:04 2006 @@ -15,8 +15,8 @@ * limitations under the License. */ -import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.math.BigDecimal; import java.sql.Connection; import java.sql.PreparedStatement; @@ -26,7 +26,8 @@ import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor; import org.apache.ojb.broker.platforms.Platform; import org.apache.ojb.broker.platforms.PlatformException; -import org.apache.ojb.broker.platforms.PlatformFactory; +import org.apache.ojb.broker.util.logging.Logger; +import org.apache.ojb.broker.util.logging.LoggerFactory; //#ifdef JDK13 import java.lang.reflect.InvocationHandler; @@ -45,6 +46,7 @@ */ public class PreparedStatementInvocationHandler implements InvocationHandler { + private static Logger log = LoggerFactory.getLogger(PreparedStatementInvocationHandler.class); private final static Integer ONE = new Integer(1); @@ -81,7 +83,7 @@ { _batchConn = batchConn; _sql = sql; - m_platform = PlatformFactory.getPlatformFor(jcd); + m_platform = jcd.getPlatform(); try { ADD_BATCH = m_platform.getClass().getMethod("addBatch",new Class[]{PreparedStatement.class}); @@ -99,8 +101,7 @@ } } - public Object invoke(Object proxy, Method method, Object[] args) - throws Throwable + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); if ( name.equals("executeUpdate") ) @@ -148,6 +149,7 @@ } catch ( PlatformException e ) { + log.error(e); if ( e.getCause() instanceof SQLException ) { throw (SQLException)e.getCause(); @@ -163,6 +165,7 @@ } catch ( PlatformException e ) { + log.error(e); if ( e.getCause() instanceof SQLException ) { throw (SQLException)e.getCause(); @@ -193,16 +196,19 @@ } catch (IllegalArgumentException ex) { - StringBuffer buffer = generateExceptionMessage(i, stmt, ex); + log.error(ex); + StringBuffer buffer = generateExceptionMessage(i, stmt, ex); throw new SQLException(buffer.toString()); } catch ( IllegalAccessException ex ) { - StringBuffer buffer = generateExceptionMessage(i, stmt, ex); + log.error(ex); + StringBuffer buffer = generateExceptionMessage(i, stmt, ex); throw new SQLException(buffer.toString()); } catch ( InvocationTargetException ex ) { + log.error(ex); Throwable th = ex.getTargetException(); if ( th == null ) @@ -232,6 +238,7 @@ } catch ( PlatformException e ) { + log.error(e); if ( e.getCause() instanceof SQLException ) { throw (SQLException)e.getCause(); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]