You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by dj...@apache.org on 2006/04/05 19:55:54 UTC
svn commit: r391691 - in /db/derby/code/trunk/java:
drda/org/apache/derby/impl/drda/ engine/org/apache/derby/iapi/jdbc/
engine/org/apache/derby/impl/jdbc/
Author: djd
Date: Wed Apr 5 10:55:53 2006
New Revision: 391691
URL: http://svn.apache.org/viewcvs?rev=391691&view=rev
Log:
DERBY-1015 (partial) Add an interface for Statement objects from the engine, EngineStatement. Removes
some use of reflection in brokered objects and the network server. Is also a step towards solving
DERBY-1158, downgrading holdabilty in global transactions.
Added:
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineStatement.java (with props)
Modified:
db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java
Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java?rev=391691&r1=391690&r2=391691&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java Wed Apr 5 10:55:53 2006
@@ -38,6 +38,7 @@
import org.apache.derby.iapi.jdbc.BrokeredConnection;
import org.apache.derby.iapi.jdbc.BrokeredPreparedStatement;
import org.apache.derby.iapi.jdbc.EngineConnection;
+import org.apache.derby.iapi.jdbc.EngineStatement;
import org.apache.derby.iapi.reference.JDBC30Translation;
import org.apache.derby.iapi.sql.execute.ExecutionContext;
import org.apache.derby.iapi.util.StringUtil;
@@ -249,65 +250,47 @@
/**
*
- * get resultSetHoldability with reflection.
- * We need to use reflection so we can use hold cursors with 1.3.1.
- * And also since our statement might be a BrokeredStatement.
+ * get resultSetHoldability.
*
* @return the resultSet holdability for the prepared statement
*
*/
protected int getResultSetHoldability() throws SQLException
{
- Statement rsstmt = null;
+ Statement rsstmt;
ResultSet rs = getResultSet();
- int holdValue = -1;
if (rs != null)
rsstmt = rs.getStatement();
else
rsstmt = getPreparedStatement();
-
- Class[] getResultSetHoldabilityParam = {};
- try {
- Method sh =
- rsstmt.getClass().getMethod("getResultSetHoldability", getResultSetHoldabilityParam);
- holdValue = ((Integer) sh.invoke(rsstmt,null)).intValue();
- }
- catch (Exception e) {
- handleReflectionException(e);
- }
+
+ int holdValue =
+ ((EngineStatement) rsstmt).getResultSetHoldability();
+
return holdValue;
}
/**
*
- * get resultSetHoldability with reflection.
- * We need to use reflection so we can use hold cursors with 1.3.1.
- * And also since our statement might be a BrokeredStatement.
+ * get resultSetHoldability.
*
* @param rs ResultSet
* @return the resultSet holdability for the prepared statement
*
*/
- protected int getResultSetHoldability(ResultSet rs) throws SQLException
+ int getResultSetHoldability(ResultSet rs) throws SQLException
{
- Statement rsstmt = null;
- int holdValue = -1;
+ Statement rsstmt;
if (rs != null)
rsstmt = rs.getStatement();
else
rsstmt = getPreparedStatement();
-
- Class[] getResultSetHoldabilityParam = {};
- try {
- Method sh =
- rsstmt.getClass().getMethod("getResultSetHoldability", getResultSetHoldabilityParam);
- holdValue = ((Integer) sh.invoke(rsstmt,null)).intValue();
- }
- catch (Exception e) {
- handleReflectionException(e);
- }
+
+ int holdValue =
+ ((EngineStatement) rsstmt).getResultSetHoldability();
+
return holdValue;
}
@@ -1595,22 +1578,10 @@
* @see java.sql.Statement#getMoreResults
*
*/
- protected boolean getMoreResults(int current) throws SQLException
- {
- boolean retVal = false;
- Class[] intPARAM = {Integer.TYPE};
- Object[] args = {new Integer(current)};
- try {
- Method sh = getPreparedStatement().getClass().getMethod("getMoreResults",intPARAM);
- Boolean retObj = (Boolean) sh.invoke(getPreparedStatement(),args);
- retVal = retObj.booleanValue();
- }
- catch (Exception e)
- {
-
- handleReflectionException(e);
- }
- return retVal;
+ private boolean getMoreResults(int current) throws SQLException
+ {
+ return
+ ((EngineStatement) getPreparedStatement()).getMoreResults(current);
}
/**
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java?rev=391691&r1=391690&r2=391691&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java Wed Apr 5 10:55:53 2006
@@ -36,7 +36,7 @@
/**
A Statement implementation that forwards all of its requests to an underlying Statement.
*/
-public class BrokeredStatement implements Statement
+public class BrokeredStatement implements EngineStatement
{
/**
@@ -441,7 +441,7 @@
*/
public final boolean getMoreResults(int current) throws SQLException
{
- return getStatement().getMoreResults( current);
+ return ((EngineStatement) getStatement()).getMoreResults( current);
}
/**
@@ -464,19 +464,7 @@
public final int getResultSetHoldability()
throws SQLException
{
- int defaultHoldability = JDBC30Translation.HOLD_CURSORS_OVER_COMMIT;
- if (JVMInfo.JDK_ID >= JVMInfo.J2SE_14) { //No need to use reflection for jdks 1.4 and higher
- defaultHoldability = getStatement().getResultSetHoldability();
- } else {
- try {
- Method sh = getStatement().getClass().getMethod("getResultSetHoldability", null);
- defaultHoldability = ((Integer)sh.invoke(getStatement(), null)).intValue();
- } catch( Exception e)
- {
- throw PublicAPI.wrapStandardException( StandardException.plainWrapException( e));
- }
- }
- return defaultHoldability;
+ return ((EngineStatement) getStatement()).getResultSetHoldability();
}
/*
Added: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineStatement.java?rev=391691&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineStatement.java (added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineStatement.java Wed Apr 5 10:55:53 2006
@@ -0,0 +1,48 @@
+/*
+
+ Derby - Class org.apache.derby.iapi.jdbc.EngineConnection
+
+ Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+package org.apache.derby.iapi.jdbc;
+
+import java.sql.SQLException;
+import java.sql.Statement;
+
+
+/**
+ * Additional methods the embedded engine exposes on its Statement object
+ * implementations. An internal api only, mainly for the network
+ * server. Allows consistent interaction between emebdded statements
+ * and brokered statements.
+ *
+ */
+public interface EngineStatement extends Statement {
+
+ /**
+ * Identical to the JDBC 3 getMoreResults(int).
+ *
+ * @see java.sql.Statement#getMoreResults(int)
+ */
+ public boolean getMoreResults(int current) throws SQLException;
+
+ /**
+ * Identical to the JDBC 3 getResultSetHoldability(int).
+ *
+ * @see java.sql.Statement#getResultSetHoldability()
+ */
+ public int getResultSetHoldability() throws SQLException;
+}
Propchange: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineStatement.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java?rev=391691&r1=391690&r2=391691&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java Wed Apr 5 10:55:53 2006
@@ -32,6 +32,7 @@
import org.apache.derby.iapi.sql.ParameterValueSet;
import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.jdbc.EngineStatement;
import java.sql.SQLException;
import java.sql.SQLWarning;
@@ -58,7 +59,7 @@
* @author ames
*/
public class EmbedStatement extends ConnectionChild
- implements java.sql.Statement {
+ implements EngineStatement {
private final java.sql.Connection applicationConnection;
Re: svn commit: r391691 - in /db/derby/code/trunk/java: drda/org/apache/derby/impl/drda/
engine/org/apache/derby/iapi/jdbc/ engine/org/apache/derby/impl/jdbc/
Posted by Bryan Pendleton <bp...@amberpoint.com>.
> Added: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineStatement.java
> URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineStatement.java?rev=391691&view=auto
> ==============================================================================
> --- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineStatement.java (added)
> +++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineStatement.java Wed Apr 5 10:55:53 2006
> @@ -0,0 +1,48 @@
> +/*
> +
> + Derby - Class org.apache.derby.iapi.jdbc.EngineConnection
Possibly a typo? Should say EngineStatement, not EngineConnection?
thanks,
bryan