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 da...@apache.org on 2006/03/18 01:35:15 UTC
svn commit: r386773 - in /db/derby/code/trunk/java:
client/org/apache/derby/client/am/ engine/org/apache/derby/impl/jdbc/
Author: davidvc
Date: Fri Mar 17 16:35:13 2006
New Revision: 386773
URL: http://svn.apache.org/viewcvs?rev=386773&view=rev
Log:
DERBY-1059 : Fix issues around calling stored procedure with out params.
Submitted by Anurag Shekhar.
Modified:
db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement40.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement40.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement40.java
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement40.java?rev=386773&r1=386772&r2=386773&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement40.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement40.java Fri Mar 17 16:35:13 2006
@@ -28,18 +28,13 @@
import java.sql.SQLXML;
-public class CallableStatement40 extends org.apache.derby.client.am.CallableStatement {
-
-
- private org.apache.derby.client.am.PreparedStatement40 ps;
-
+public class CallableStatement40 extends org.apache.derby.client.am.CallableStatement {
public CallableStatement40(Agent agent,
Connection connection,
String sql,
int type, int concurrency, int holdability) throws SqlException {
- super(agent, connection, sql, type, concurrency, holdability);
- ps = new PreparedStatement40(agent, connection, sql, type, concurrency, holdability, java.sql.Statement.NO_GENERATED_KEYS, null);
+ super(agent, connection, sql, type, concurrency, holdability);
}
@@ -117,42 +112,26 @@
* The methods from PreparedStatement for JDBC 4.0
*********************************************************************************************************/
public void setNString(int index, String value) throws SQLException {
- ps.setNString(index,value);
+ throw SQLExceptionFactory.notImplemented ("setNString (int, String)");
}
public void setNCharacterStream(int index, Reader value, long length) throws SQLException {
- ps.setNCharacterStream(index,value,length);
+ throw SQLExceptionFactory.notImplemented ("setNCharacterStream " +
+ "(int,Reader,long)");
}
public void setNClob(int index, NClob value) throws SQLException {
- ps.setNClob(index,value);
+ throw SQLExceptionFactory.notImplemented ("setNClob (int, NClob)");
}
- public void setClob(int parameterIndex, Reader reader, long length)
- throws SQLException {
- ps.setClob(parameterIndex,reader,length);
- }
-
- public void setBlob(int parameterIndex, InputStream inputStream, long length)
- throws SQLException {
- ps.setBlob(parameterIndex,inputStream,length);
- }
public void setNClob(int parameterIndex, Reader reader, long length)
throws SQLException {
- ps.setNClob(parameterIndex,reader,length);
+ throw SQLExceptionFactory.notImplemented ("setNClob (int, " +
+ "Reader, long)");
}
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException {
- ps.setSQLXML(parameterIndex,xmlObject);
- }
-
- public void setPoolable(boolean poolable)
- throws SQLException {
- ps.setPoolable(poolable);
+ throw SQLExceptionFactory.notImplemented ("setSQLXML (int, SQLXML)");
}
- public boolean isPoolable()
- throws SQLException {
- return ps.isPoolable();
- }
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java?rev=386773&r1=386772&r2=386773&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java Fri Mar 17 16:35:13 2006
@@ -20,6 +20,8 @@
package org.apache.derby.client.am;
+import java.io.InputStream;
+import java.io.Reader;
import java.sql.SQLException;
public class PreparedStatement extends Statement
@@ -47,6 +49,10 @@
boolean[] parameterSet_;
boolean[] parameterRegistered_;
+
+ // By default a PreparedStatement is poolable when it is created
+ //required for jdbc4.0 methods
+ private boolean isPoolable = true;
void setInput(int parameterIndex, Object input) {
parameters_[parameterIndex - 1] = input;
@@ -2015,5 +2021,123 @@
if(removeListener)
connection_.CommitAndRollbackListeners_.remove(this);
}
+
+ //jdbc 4.0 methods
+ /**
+ * Sets the designated parameter to a Reader object.
+ *
+ * @param parameterIndex index of the first parameter is 1, the second is 2, ...
+ * @param reader An object that contains the data to set the parameter value to.
+ * @param length the number of characters in the parameter data.
+ * @throws SQLException if parameterIndex does not correspond to a parameter
+ * marker in the SQL statement, or if the length specified is less than zero.
+ *
+ */
+
+ public void setClob(int parameterIndex, Reader reader, long length)
+ throws SQLException{
+ synchronized (connection_) {
+ if (agent_.loggingEnabled()) {
+ agent_.logWriter_.traceEntry(this, "setClob",
+ parameterIndex, reader, new Long(length));
+ }
+ if(length > Integer.MAX_VALUE)
+ throw new SQLException("CLOB length exceeds maximum " +
+ "possible limit");
+ else
+ setInput(parameterIndex, new Clob(agent_, reader, (int)length));
+ }
+ }
+
+ /**
+ * Sets the designated parameter to a InputStream object.
+ *
+ * @param parameterIndex index of the first parameter is 1,
+ * the second is 2, ...
+ * @param inputStream An object that contains the data to set the parameter
+ * value to.
+ * @param length the number of bytes in the parameter data.
+ * @throws SQLException if parameterIndex does not correspond
+ * to a parameter marker in the SQL statement, if the length specified
+ * is less than zero or if the number of bytes in the inputstream does not match
+ * the specfied length.
+ *
+ */
+
+ public void setBlob(int parameterIndex, InputStream inputStream, long length)
+ throws SQLException{
+ synchronized (connection_) {
+ if (agent_.loggingEnabled()) {
+ agent_.logWriter_.traceEntry(this, "setBlob", parameterIndex,
+ inputStream, new Long(length));
+ }
+ if(length > Integer.MAX_VALUE)
+ throw new SQLException("BLOB length exceeds maximum " +
+ "possible limit");
+ else {
+ try {
+ setBinaryStreamX(parameterIndex, inputStream, (int)length);
+ } catch(SqlException se){
+ throw se.getSQLException();
+ }
+ }
+ }
+ }
+
+ /**
+ * Requests that a PreparedStatement be pooled or not.
+ *
+ * @param poolable requests that the statement be pooled if true and that the
+ * statement not be pooled if false
+ * @throws SQLException if the PreparedStatement has been closed.
+ */
+
+ public void setPoolable(boolean poolable)
+ throws SQLException {
+ try
+ {
+ synchronized (connection_) {
+ if (agent_.loggingEnabled()) {
+ agent_.logWriter_.traceEntry(this, "setPoolable", poolable);
+ }
+ // Assert the statement has not been closed
+ checkForClosedStatement();
+
+ isPoolable = poolable;
+ }
+ }
+ catch (SqlException se)
+ {
+ throw se.getSQLException();
+ }
+ }
+
+ /**
+ * Returns the value of the statements poolable hint, indicating whether
+ * pooling of the statement is requested.
+ *
+ * @return The value of the statement's poolable hint.
+ * @throws SQLException if the PreparedStatement has been closed.
+ */
+
+ public boolean isPoolable()
+ throws SQLException{
+ try
+ {
+ synchronized (connection_) {
+ if (agent_.loggingEnabled()) {
+ agent_.logWriter_.traceEntry(this, "isPoolable");
+ }
+ // Assert the statement has not been closed
+ checkForClosedStatement();
+
+ return isPoolable;
+ }
+ }
+ catch (SqlException se)
+ {
+ throw se.getSQLException();
+ }
+ }
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement40.java?rev=386773&r1=386772&r2=386773&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement40.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement40.java Fri Mar 17 16:35:13 2006
@@ -66,66 +66,6 @@
throw SQLExceptionFactory.notImplemented ("setNClob (int, NClob)");
}
- /**
- * Sets the designated parameter to a Reader object.
- *
- * @param parameterIndex index of the first parameter is 1, the second is 2, ...
- * @param reader An object that contains the data to set the parameter value to.
- * @param length the number of characters in the parameter data.
- * @throws SQLException if parameterIndex does not correspond to a parameter
- * marker in the SQL statement, or if the length specified is less than zero.
- *
- */
-
- public void setClob(int parameterIndex, Reader reader, long length)
- throws SQLException{
- synchronized (connection_) {
- if (agent_.loggingEnabled()) {
- agent_.logWriter_.traceEntry(this, "setClob",
- parameterIndex, reader, new Long(length));
- }
- if(length > Integer.MAX_VALUE)
- throw new SQLException("CLOB length exceeds maximum " +
- "possible limit");
- else
- setInput(parameterIndex, new Clob(agent_, reader, (int)length));
- }
- }
-
- /**
- * Sets the designated parameter to a InputStream object.
- *
- * @param parameterIndex index of the first parameter is 1,
- * the second is 2, ...
- * @param inputStream An object that contains the data to set the parameter
- * value to.
- * @param length the number of bytes in the parameter data.
- * @throws SQLException if parameterIndex does not correspond
- * to a parameter marker in the SQL statement, if the length specified
- * is less than zero or if the number of bytes in the inputstream does not match
- * the specfied length.
- *
- */
-
- public void setBlob(int parameterIndex, InputStream inputStream, long length)
- throws SQLException{
- synchronized (connection_) {
- if (agent_.loggingEnabled()) {
- agent_.logWriter_.traceEntry(this, "setBlob", parameterIndex,
- inputStream, new Long(length));
- }
- if(length > Integer.MAX_VALUE)
- throw new SQLException("BLOB length exceeds maximum " +
- "possible limit");
- else {
- try {
- setBinaryStreamX(parameterIndex, inputStream, (int)length);
- } catch(SqlException se){
- throw se.getSQLException();
- }
- }
- }
- }
public void setNClob(int parameterIndex, Reader reader, long length)
throws SQLException{
throw SQLExceptionFactory.notImplemented ("setNClob (int, Reader, long)");
@@ -134,61 +74,5 @@
public void setSQLXML(int parameterIndex, SQLXML xmlObject)
throws SQLException{
throw SQLExceptionFactory.notImplemented ("setSQLXML (int, SQLXML)");
- }
-
- /**
- * Requests that a PreparedStatement be pooled or not.
- *
- * @param poolable requests that the statement be pooled if true and that the
- * statement not be pooled if false
- * @throws SQLException if the PreparedStatement has been closed.
- */
-
- public void setPoolable(boolean poolable)
- throws SQLException {
- try
- {
- synchronized (connection_) {
- if (agent_.loggingEnabled()) {
- agent_.logWriter_.traceEntry(this, "setPoolable", poolable);
- }
- // Assert the statement has not been closed
- checkForClosedStatement();
-
- isPoolable = poolable;
- }
- }
- catch (SqlException se)
- {
- throw se.getSQLException();
- }
- }
-
- /**
- * Returns the value of the statements poolable hint, indicating whether
- * pooling of the statement is requested.
- *
- * @return The value of the statement's poolable hint.
- * @throws SQLException if the PreparedStatement has been closed.
- */
-
- public boolean isPoolable()
- throws SQLException{
- try
- {
- synchronized (connection_) {
- if (agent_.loggingEnabled()) {
- agent_.logWriter_.traceEntry(this, "isPoolable");
- }
- // Assert the statement has not been closed
- checkForClosedStatement();
-
- return isPoolable;
- }
- }
- catch (SqlException se)
- {
- throw se.getSQLException();
- }
- }
+ }
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java?rev=386773&r1=386772&r2=386773&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java Fri Mar 17 16:35:13 2006
@@ -29,22 +29,13 @@
public class EmbedCallableStatement40 extends EmbedCallableStatement30 {
-
-
- EmbedPreparedStatement40 ps;
+
/** Creates a new instance of EmbedCallableStatement40 */
public EmbedCallableStatement40(EmbedConnection conn, String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) throws SQLException{
- super(conn, sql, resultSetType, resultSetConcurrency, resultSetHoldability);
- ps = new EmbedPreparedStatement40(conn, sql, false,
- resultSetType,
- resultSetConcurrency,
- resultSetHoldability,
- java.sql.Statement.NO_GENERATED_KEYS,
- null,
- null);
+ super(conn, sql, resultSetType, resultSetConcurrency, resultSetHoldability);
}
@@ -123,46 +114,27 @@
public void setRowId(int parameterIndex, RowId x) throws SQLException{
- ps.setRowId(parameterIndex,x);
+ throw Util.notImplemented("setRowId(int, RowId)");
}
public void setNString(int index, String value) throws SQLException{
- ps.setNString(index,value);
+ throw Util.notImplemented("setNString (int,value)");
}
public void setNCharacterStream(int index, Reader value, long length) throws SQLException{
- ps.setNCharacterStream(index,value,length);
+ throw Util.notImplemented ("setNCharacterStream (int, Reader, long)");
}
public void setNClob(int index, NClob value) throws SQLException{
- ps.setNClob(index,value);
- }
-
- public void setClob(int parameterIndex, Reader reader, long length)
- throws SQLException{
- ps.setClob(parameterIndex,reader,length);
+ throw Util.notImplemented ("setNClob (int, NClob)");
}
- public void setBlob(int parameterIndex, InputStream inputStream, long length)
- throws SQLException{
- ps.setBlob(parameterIndex,inputStream,length);
- }
public void setNClob(int parameterIndex, Reader reader, long length)
throws SQLException{
- ps.setNClob(parameterIndex,reader,length);
- }
+ throw Util.notImplemented ("setNClob(int,reader,length)");
+ }
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException{
- ps.setSQLXML(parameterIndex,xmlObject);
- }
-
- public void setPoolable(boolean poolable)
- throws SQLException{
- ps.setPoolable(poolable);
- }
-
- public boolean isPoolable()
- throws SQLException{
- return ps.isPoolable();
- }
+ throw Util.notImplemented ("setSQLXML (int, SQLXML)");
+ }
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java?rev=386773&r1=386772&r2=386773&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 Fri Mar 17 16:35:13 2006
@@ -93,6 +93,10 @@
protected PreparedStatement preparedStatement;
private Activation activation;
+ // By default a PreparedStatement is poolable when it is created
+ //required for jdbc4.0 methods
+ private boolean isPoolable = true;
+
/*
Constructor assumes caller will setup context stack
and restore it.
@@ -1427,4 +1431,90 @@
sourceType);
return se;
}
+
+ //jdbc 4.0 methods
+
+
+ /**
+ * Sets the designated parameter to a Reader object.
+ *
+ * @param parameterIndex index of the first parameter is 1, the second is 2, ...
+ * @param reader An object that contains the data to set the parameter value to.
+ * @param length the number of characters in the parameter data.
+ * @throws SQLException if parameterIndex does not correspond to a parameter
+ * marker in the SQL statement, or if the length specified is less than zero.
+ *
+ */
+
+
+ public void setClob(int parameterIndex, Reader reader, long length)
+ throws SQLException{
+ int colType;
+ synchronized(getConnectionSynchronization()) {
+ colType = getParameterJDBCType(parameterIndex);
+ if(colType != Types.CLOB)
+ throw dataTypeConversion(parameterIndex, "java.sql.Clob");
+
+ setCharacterStreamInternal(parameterIndex,reader,length);
+ }
+ }
+
+ /**
+ * Sets the designated parameter to a InputStream object.
+ *
+ * @param parameterIndex index of the first parameter is 1,
+ * the second is 2, ...
+ * @param inputStream An object that contains the data to set the parameter
+ * value to.
+ * @param length the number of bytes in the parameter data.
+ * @throws SQLException if parameterIndex does not correspond
+ * to a parameter marker in the SQL statement, if the length specified
+ * is less than zero or if the number of bytes in the inputstream does not match
+ * the specfied length.
+ */
+
+
+ public void setBlob(int parameterIndex, InputStream inputStream, long length)
+ throws SQLException{
+ int colType;
+ synchronized (getConnectionSynchronization()) {
+ colType = getParameterJDBCType(parameterIndex);
+ if (colType != Types.BLOB)
+ throw dataTypeConversion(parameterIndex, "java.sql.Blob");
+
+ setBinaryStreamInternal(parameterIndex,inputStream,length);
+ }
+ }
+ /**
+ * Requests that a PreparedStatement be pooled or not.
+ *
+ * @param poolable requests that the statement be pooled if true and that the
+ * statement not be pooled if false
+ * @throws SQLException if the PreparedStatement has been closed.
+ */
+
+ public void setPoolable(boolean poolable)
+ throws SQLException {
+ // Assert the statement is still active (not closed)
+ checkStatus();
+
+ isPoolable = poolable;
+ }
+
+ /**
+ * Returns the value of the statements poolable hint, indicating whether
+ * pooling of the statement is requested.
+ *
+ * @return The value of the statement's poolable hint.
+ * @throws SQLException if the PreparedStatement has been closed.
+ */
+
+ public boolean isPoolable()
+ throws SQLException {
+ // Assert the statement is still active (not closed)
+ checkStatus();
+
+ return isPoolable;
+ }
+
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement40.java?rev=386773&r1=386772&r2=386773&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement40.java Fri Mar 17 16:35:13 2006
@@ -31,9 +31,6 @@
import org.apache.derby.iapi.error.StandardException;
public class EmbedPreparedStatement40 extends EmbedPreparedStatement30 {
-
- // By default a PreparedStatement is poolable when it is created
- private boolean isPoolable = true;
public EmbedPreparedStatement40(EmbedConnection conn, String sql, boolean forMetaData,
int resultSetType, int resultSetConcurrency, int resultSetHoldability,
@@ -56,59 +53,7 @@
public void setNClob(int index, NClob value) throws SQLException{
throw Util.notImplemented();
- }
-
-
- /**
- * Sets the designated parameter to a Reader object.
- *
- * @param parameterIndex index of the first parameter is 1, the second is 2, ...
- * @param reader An object that contains the data to set the parameter value to.
- * @param length the number of characters in the parameter data.
- * @throws SQLException if parameterIndex does not correspond to a parameter
- * marker in the SQL statement, or if the length specified is less than zero.
- *
- */
-
-
- public void setClob(int parameterIndex, Reader reader, long length)
- throws SQLException{
- int colType;
- synchronized(getConnectionSynchronization()) {
- colType = getParameterJDBCType(parameterIndex);
- if(colType != Types.CLOB)
- throw dataTypeConversion(parameterIndex, "java.sql.Clob");
-
- setCharacterStreamInternal(parameterIndex,reader,length);
- }
- }
-
- /**
- * Sets the designated parameter to a InputStream object.
- *
- * @param parameterIndex index of the first parameter is 1,
- * the second is 2, ...
- * @param inputStream An object that contains the data to set the parameter
- * value to.
- * @param length the number of bytes in the parameter data.
- * @throws SQLException if parameterIndex does not correspond
- * to a parameter marker in the SQL statement, if the length specified
- * is less than zero or if the number of bytes in the inputstream does not match
- * the specfied length.
- */
-
-
- public void setBlob(int parameterIndex, InputStream inputStream, long length)
- throws SQLException{
- int colType;
- synchronized (getConnectionSynchronization()) {
- colType = getParameterJDBCType(parameterIndex);
- if (colType != Types.BLOB)
- throw dataTypeConversion(parameterIndex, "java.sql.Blob");
-
- setBinaryStreamInternal(parameterIndex,inputStream,length);
- }
- }
+ }
public void setNClob(int parameterIndex, Reader reader, long length)
throws SQLException{
@@ -118,36 +63,5 @@
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException{
throw Util.notImplemented();
}
-
- /**
- * Requests that a PreparedStatement be pooled or not.
- *
- * @param poolable requests that the statement be pooled if true and that the
- * statement not be pooled if false
- * @throws SQLException if the PreparedStatement has been closed.
- */
-
- public void setPoolable(boolean poolable)
- throws SQLException {
- // Assert the statement is still active (not closed)
- checkStatus();
-
- isPoolable = poolable;
- }
-
- /**
- * Returns the value of the statements poolable hint, indicating whether
- * pooling of the statement is requested.
- *
- * @return The value of the statement's poolable hint.
- * @throws SQLException if the PreparedStatement has been closed.
- */
+}
- public boolean isPoolable()
- throws SQLException {
- // Assert the statement is still active (not closed)
- checkStatus();
-
- return isPoolable;
- }
-}