Re: Bug with callable statement and output parameters - Mailing list pgsql-jdbc
From | Dave Cramer |
---|---|
Subject | Re: Bug with callable statement and output parameters |
Date | |
Msg-id | B8BAE173-D49A-4C20-82A9-6DA0950F4CF9@fastcrypt.com Whole thread Raw |
In response to | Re: Bug with callable statement and output parameters (Kris Jurka <books@ejurka.com>) |
Responses |
Re: Bug with callable statement and output parameters
|
List | pgsql-jdbc |
Patch attached for review and test Index: org/postgresql/jdbc2/AbstractJdbc2Statement.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/ AbstractJdbc2Statement.java,v retrieving revision 1.88 diff -c -r1.88 AbstractJdbc2Statement.java *** org/postgresql/jdbc2/AbstractJdbc2Statement.java 1 Feb 2006 18:52:13 -0000 1.88 --- org/postgresql/jdbc2/AbstractJdbc2Statement.java 27 Apr 2006 16:00:50 -0000 *************** *** 366,392 **** // figure out how many columns int cols = rs.getMetaData().getColumnCount(); ! callResult = new Object[cols]; // move them into the result set ! for ( int i=0; i < cols; i++) { ! callResult[i] = rs.getObject(i+1); ! int columnType = rs.getMetaData().getColumnType(1); ! if (columnType != functionReturnType[i]) { // this is here for the sole purpose of passing the cts ! if ( columnType == Types.DOUBLE && functionReturnType[i] == Types.REAL ) { // return it as a float ! if ( callResult[i] != null) ! callResult[i] = new Float(((Double) callResult[i]).floatValue()); } else { ! throw new PSQLException (GT.tr("A CallableStatement function was executed and the return was of type {0} however type {1} was registered.", ! new Object[]{ ! "java.sql.Types=" + columnType, "java.sql.Types=" + functionReturnType[i] }), PSQLState.DATA_TYPE_MISMATCH); } } --- 366,401 ---- // figure out how many columns int cols = rs.getMetaData().getColumnCount(); ! ! // allocate enough space for all possible parameters without regard to in/out ! callResult = new Object [preparedParameters.getParameterCount()+1]; // move them into the result set ! for ( int i=0,j=0; i < cols; i++,j++) { ! // find the next out parameter, the assumption is that the functionReturnType ! // array will be initialized with 0 and only out parameters will have values ! // other than 0. 0 is the value for java.sql.Types.NULL, which should not ! // conflict ! while( j< functionReturnType.length && functionReturnType[j]==0) j++; ! ! callResult[j] = rs.getObject(i+1); ! int columnType = rs.getMetaData().getColumnType(i+1); ! ! if (columnType != functionReturnType[j]) { // this is here for the sole purpose of passing the cts ! if ( columnType == Types.DOUBLE && functionReturnType[j] == Types.REAL ) { // return it as a float ! if ( callResult[j] != null) ! callResult[j] = new Float(((Double) callResult[j]).floatValue()); } else { ! throw new PSQLException (GT.tr("A CallableStatement function was executed and the out parameter {0} was of type {1} however type {2} was registered.", ! new Object[]{""+i+1, ! "java.sql.Types=" + columnType, "java.sql.Types=" + functionReturnType[j] }), PSQLState.DATA_TYPE_MISMATCH); } }
pgsql-jdbc by date: