activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r787990 - in /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc: DefaultDatabaseLocker.java adapter/DefaultJDBCAdapter.java
Date Wed, 24 Jun 2009 12:04:50 GMT
Author: gtully
Date: Wed Jun 24 12:04:50 2009
New Revision: 787990

URL: http://svn.apache.org/viewvc?rev=787990&view=rev
Log:
apply modified suggstion from https://issues.apache.org/activemq/browse/AMQ-1191 - executeQuery
conditional on statement metadata which works when statement does not return a result set
like with derby which is used in the unit tests

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/DefaultDatabaseLocker.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/DefaultDatabaseLocker.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/DefaultDatabaseLocker.java?rev=787990&r1=787989&r2=787990&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/DefaultDatabaseLocker.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/DefaultDatabaseLocker.java
Wed Jun 24 12:04:50 2009
@@ -19,6 +19,8 @@
 import java.io.IOException;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
 
 import javax.sql.DataSource;
@@ -64,7 +66,13 @@
                 connection.setAutoCommit(false);
                 String sql = statements.getLockCreateStatement();
                 statement = connection.prepareStatement(sql);
-                statement.execute();
+                if (statement.getMetaData() != null) {
+                    ResultSet rs = statement.executeQuery();
+                    // if not already locked the statement below blocks until lock acquired
+                    rs.next();
+                } else {
+                    statement.execute();
+                }
                 break;
             } catch (Exception e) {
                 if (stopping) {

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java?rev=787990&r1=787989&r2=787990&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java
Wed Jun 24 12:04:50 2009
@@ -291,7 +291,7 @@
                 throw new SQLException("Failed to remove message");
             }
         } finally {
-            if (!this.batchStatments) {
+            if (!this.batchStatments && s != null) {
                 s.close();
             }
         }



Mime
View raw message