db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davi...@apache.org
Subject svn commit: r421435 - in /db/derby/code/trunk/java: drda/org/apache/derby/impl/drda/ engine/org/apache/derby/iapi/jdbc/ engine/org/apache/derby/impl/jdbc/
Date Wed, 12 Jul 2006 22:05:50 GMT
Author: davidvc
Date: Wed Jul 12 15:05:50 2006
New Revision: 421435

URL: http://svn.apache.org/viewvc?rev=421435&view=rev
Log:
DERBY-1015: Define interface between network server and engine through 
Java interfaces.  Contributed by Sunitha Kambhampati.  Passes 
derbynetclientmats.


Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterSetMetaData.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java?rev=421435&r1=421434&r2=421435&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java Wed Jul 12
15:05:50 2006
@@ -56,7 +56,7 @@
 import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
 import org.apache.derby.iapi.tools.i18n.LocalizedResource;
-import org.apache.derby.impl.jdbc.EmbedParameterSetMetaData;
+import org.apache.derby.iapi.jdbc.EngineParameterMetaData;
 import org.apache.derby.impl.jdbc.EmbedSQLException;
 import org.apache.derby.impl.jdbc.Util;
 
@@ -3948,7 +3948,7 @@
 		String strVal;
 		PreparedStatement ps = stmt.getPreparedStatement();
 		int codePoint;
-		EmbedParameterSetMetaData pmeta = null;
+		EngineParameterMetaData pmeta = null;
 		Vector paramDrdaTypes = new Vector();
 		Vector paramLens = new Vector();
 		ArrayList paramExtPositions = null;
@@ -4095,7 +4095,7 @@
      * @throws SQLException
 	 */
 	private ArrayList readAndSetParams(int i, DRDAStatement stmt, int
-									   drdaType, EmbedParameterSetMetaData pmeta,
+									   drdaType, EngineParameterMetaData pmeta,
 									   ArrayList paramExtPositions,
 									   int paramLenNumBytes)
 				throws DRDAProtocolException, SQLException
@@ -5804,7 +5804,7 @@
 	{
 		PreparedStatement ps = stmt.getPreparedStatement();
 		ResultSetMetaData rsmeta = ps.getMetaData();
-		EmbedParameterSetMetaData pmeta = stmt.getParameterMetaData();
+		EngineParameterMetaData pmeta = stmt.getParameterMetaData();
 		int numElems = 0;
 		if (e == null || e instanceof SQLWarning)
 		{
@@ -5856,7 +5856,7 @@
 
 		ResultSet rs = null;
 		ResultSetMetaData rsmeta = null;
-		EmbedParameterSetMetaData pmeta = null;
+		EngineParameterMetaData pmeta = null;
 		if (!stmt.needsToSendParamData)
 			rs = stmt.getResultSet();
 		if (rs == null)		// this is a CallableStatement, use parameter meta data
@@ -5952,7 +5952,7 @@
      * @throws SQLException
 	 */
 	private void writeSQLDTAGRP(DRDAStatement stmt, ResultSetMetaData rsmeta, 
-								EmbedParameterSetMetaData pmeta,
+								EngineParameterMetaData pmeta,
 								int colStart, int colEnd, boolean first)
 		throws DRDAProtocolException, SQLException
 	{
@@ -6695,7 +6695,7 @@
 	 * @throws DRDAProtocolException
      * @throws SQLException
 	 */
-	private void writeSQLDAGRP(ResultSetMetaData rsmeta, EmbedParameterSetMetaData pmeta, int
elemNum, boolean rtnOutput)
+	private void writeSQLDAGRP(ResultSetMetaData rsmeta, EngineParameterMetaData pmeta, int
elemNum, boolean rtnOutput)
 		throws DRDAProtocolException, SQLException
 	{
 		//jdbc uses offset of 1
@@ -6831,14 +6831,14 @@
 	}
 
   
-	private void writeSQLUDTGRP(ResultSetMetaData rsmeta, EmbedParameterSetMetaData pmeta, int
jdbcElemNum, boolean rtnOutput)
+	private void writeSQLUDTGRP(ResultSetMetaData rsmeta, EngineParameterMetaData pmeta, int
jdbcElemNum, boolean rtnOutput)
 		throws DRDAProtocolException,SQLException
 	{
 		writer.writeByte(CodePoint.NULLDATA);
 
 	}
 
-	private void writeSQLDOPTGRP(ResultSetMetaData rsmeta, EmbedParameterSetMetaData pmeta,
int jdbcElemNum, boolean rtnOutput)
+	private void writeSQLDOPTGRP(ResultSetMetaData rsmeta, EngineParameterMetaData pmeta, int
jdbcElemNum, boolean rtnOutput)
 		throws DRDAProtocolException,SQLException
 	{
 
@@ -6858,7 +6858,7 @@
 	}
 
 
-	private void writeSQLDXGRP(ResultSetMetaData rsmeta, EmbedParameterSetMetaData pmeta, int
jdbcElemNum, boolean rtnOutput)
+	private void writeSQLDXGRP(ResultSetMetaData rsmeta, EngineParameterMetaData pmeta, int
jdbcElemNum, boolean rtnOutput)
 		throws DRDAProtocolException,SQLException
 	{
 		// Null indicator indicates we have data

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAStatement.java?rev=421435&r1=421434&r2=421435&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 Jul 12
15:05:50 2006
@@ -39,10 +39,11 @@
 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.jdbc.EnginePreparedStatement;
+import org.apache.derby.iapi.jdbc.EngineParameterMetaData;
 import org.apache.derby.iapi.reference.JDBC30Translation;
 import org.apache.derby.iapi.sql.execute.ExecutionContext;
 import org.apache.derby.iapi.util.StringUtil;
-import org.apache.derby.impl.jdbc.EmbedParameterSetMetaData;
 import org.apache.derby.impl.jdbc.Util;
 
 /**
@@ -81,7 +82,7 @@
 	protected byte [] rslsetflg;		// Result Set Flags
 	protected int maxrslcnt;			// Maximum Result set count
 	protected PreparedStatement ps;     // Prepared statement
-	protected EmbedParameterSetMetaData stmtPmeta; // param metadata
+	protected EngineParameterMetaData stmtPmeta; // param metadata
 	protected boolean isCall;
 	protected String procName;			// callable statement's method name
 	private   int[] outputTypes;		// jdbc type for output parameter or NOT_OUTPUT_PARAM
@@ -537,11 +538,7 @@
 	 */
 	protected PreparedStatement getPreparedStatement() throws SQLException
 	{
-		if (ps instanceof BrokeredPreparedStatement)
-			return (PreparedStatement)(
-						   ((BrokeredPreparedStatement) ps).getStatement());
-		else
-			return ps;
+		return ps;
 	}
 
 
@@ -1153,7 +1150,7 @@
 	{
 		if (ps != null && ps instanceof CallableStatement)
 		{
-			EmbedParameterSetMetaData pmeta = 	getParameterMetaData();
+			EngineParameterMetaData pmeta = 	getParameterMetaData();
 
 			return Math.min(pmeta.getPrecision(index),
 							FdocaConstants.NUMERIC_MAX_PRECISION);
@@ -1174,7 +1171,7 @@
 	{
 		if (ps != null && ps instanceof CallableStatement)
 		{
-			EmbedParameterSetMetaData pmeta = 	getParameterMetaData();
+			EngineParameterMetaData pmeta = 	getParameterMetaData();
 			return Math.min(pmeta.getScale(index),FdocaConstants.NUMERIC_MAX_PRECISION);
 		}
 		else 
@@ -1324,7 +1321,7 @@
 
 	private void setupCallableStatementParams(CallableStatement cs) throws SQLException
 	{
-		EmbedParameterSetMetaData pmeta = 	getParameterMetaData();
+		EngineParameterMetaData pmeta = 	getParameterMetaData();
 		int numElems = pmeta.getParameterCount();
 
 		for ( int i = 0; i < numElems; i ++)
@@ -1555,31 +1552,21 @@
 
 	
 	/** 
-	 * Get parameter metadata from EmbedPreparedStatement or 
-	 * BrokeredPreparedStatement. We use reflection because we don't know which
-	 * we have.
-	 * 
-	 * @return EmbedParameterSetMetaData for the prepared statement. 
+	 * Retrieve the ParameterMetaData for the prepared statement. 
+     * To do so, use the engine defined interfaces:
+     * @see org.apache.derby.iapi.jdbc.EnginePreparedStatement
+     * @see org.apache.derby.iapi.jdbc.EngineParameterMetaData 
+	 * @return EngineParameterMetaData for the prepared statement. 
 	 * Note: there is no separate BrokeredParameterSetMetaData.
 	 */
-	protected EmbedParameterSetMetaData getParameterMetaData() throws SQLException
+	protected EngineParameterMetaData getParameterMetaData() throws SQLException
 	{
 		if (stmtPmeta != null)
 			return stmtPmeta;
 
-		EmbedParameterSetMetaData pmeta = null;
-		Class[] getParameterMetaDataParam = {};
-		try {
-			Method sh =
-				getPreparedStatement().getClass().getMethod("getEmbedParameterSetMetaData", getParameterMetaDataParam);
-			pmeta = (EmbedParameterSetMetaData)
-				sh.invoke(getPreparedStatement(),null);
-			stmtPmeta = pmeta;
-		}
-		catch (Exception e) {
-			handleReflectionException(e);
-		}
-		return stmtPmeta;
+		stmtPmeta = ((EnginePreparedStatement)ps).getEmbedParameterSetMetaData();
+        
+        return stmtPmeta;
 	}
 	
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java?rev=421435&r1=421434&r2=421435&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
Wed Jul 12 15:05:50 2006
@@ -32,7 +32,7 @@
 	obtained through the BrokeredStatementControl getRealPreparedStatement method.
  */
 public class BrokeredPreparedStatement extends BrokeredStatement
-	implements PreparedStatement
+	implements EnginePreparedStatement
 {
 
 	/**
@@ -46,6 +46,21 @@
 		this.sql = sql;
     }
 
+    /**
+     * Imitate the getParameterMetaData() function in JDBC 3.0
+     *
+     * Retrieves the number, types and properties of this PreparedStatement
+     * object's parameters.
+     *
+     * @return a EngineParameterMetaData object that contains information about the
+     * number, types and properties of this PreparedStatement object's parameters.
+     * @exception SQLException if a database access error occurs
+     */
+    public EngineParameterMetaData getEmbedParameterSetMetaData()
+    throws SQLException
+    {
+        return ((EnginePreparedStatement)getPreparedStatement()).getEmbedParameterSetMetaData();
+    }
 	/**
      * A prepared SQL query is executed and its ResultSet is returned.
      *

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterSetMetaData.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterSetMetaData.java?rev=421435&r1=421434&r2=421435&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterSetMetaData.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterSetMetaData.java
Wed Jul 12 15:05:50 2006
@@ -26,6 +26,7 @@
 import org.apache.derby.iapi.types.DataTypeUtilities;
 import org.apache.derby.iapi.reference.JDBC30Translation;
 import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.jdbc.EngineParameterMetaData;
 
 import java.sql.SQLException;
 import java.sql.Types;
@@ -37,13 +38,12 @@
  * It provides the parameter meta data for callable & prepared statements.
  * The subclass in Local30 actually implements ParameterMetaData interface.
  *
- * Our middle-tier servers or tools (eg. drda network server) can use it this way:
- * import org.apache.derby.impl.jdbc.EmbedPreparedStatement;
- * import org.apache.derby.impl.jdbc.EmbedParameterSetMetaData;
- *
- *   EmbedParameterSetMetaData pmeta = ((EmbedPreparedStatement) ps).getEmbedParameterSetMetaData();
+ * For use of ParameterMetaData functionality in network server, please do not use
+ * this class directly. Instead use the method available on EnginePreparedStatement
+ * @see org.apache.derby.iapi.jdbc.EngineParameterMetaData
+ * @see org.apache.derby.iapi.jdbc.EnginePreparedStatement
  */
-public class EmbedParameterSetMetaData
+public class EmbedParameterSetMetaData implements EngineParameterMetaData
     {
 
     private final ParameterValueSet pvs;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java?rev=421435&r1=421434&r2=421435&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
Wed Jul 12 15:05:50 2006
@@ -70,6 +70,8 @@
 import java.sql.Types;
 
 import org.apache.derby.iapi.jdbc.BrokeredConnectionControl;
+import org.apache.derby.iapi.jdbc.EngineParameterMetaData;
+import org.apache.derby.iapi.jdbc.EnginePreparedStatement;
 
 /**
  *
@@ -81,7 +83,7 @@
  */
 public abstract class EmbedPreparedStatement
 	extends EmbedStatement
-	implements java.sql.PreparedStatement
+	implements EnginePreparedStatement
 {
 
 	//Moving jdbc2.0 batch related code in this class because callableStatement in jdbc 20 needs
@@ -1444,11 +1446,11 @@
     * Retrieves the number, types and properties of this PreparedStatement
     * object's parameters.
     *
-    * @return a EmbedParameterSetMetaData object that contains information about the
+    * @return a EngineParameterMetaData object that contains information about the
     * number, types and properties of this PreparedStatement object's parameters.
     * @exception SQLException if a database access error occurs
 	*/
-	public EmbedParameterSetMetaData getEmbedParameterSetMetaData()
+	public EngineParameterMetaData getEmbedParameterSetMetaData()
     	throws SQLException
 	{
 	  checkExecStatus();



Mime
View raw message