@@ -80,79 +80,79 @@ public int executeUpdate() throws SQLException {
8080
8181 @ Override
8282 public boolean executeWithFlags (int flags ) throws SQLException {
83- synchronized (this ) {
84- boolean hasResultSet = super .executeWithFlags (flags );
85- int [] functionReturnType = this .functionReturnType ;
86- if (!isFunction || !returnTypeSet || functionReturnType == null ) {
87- return hasResultSet ;
88- }
83+ boolean hasResultSet = super .executeWithFlags (flags );
84+ int [] functionReturnType = this .functionReturnType ;
85+ if (!isFunction || !returnTypeSet || functionReturnType == null ) {
86+ return hasResultSet ;
87+ }
8988
90- // If we are executing and there are out parameters
91- // callable statement function set the return data
92- if (!hasResultSet ) {
93- throw new PSQLException (GT .tr ("A CallableStatement was executed with nothing returned." ),
94- PSQLState .NO_DATA );
95- }
89+ // If we are executing and there are out parameters
90+ // callable statement function set the return data
91+ if (!hasResultSet ) {
92+ throw new PSQLException (GT .tr ("A CallableStatement was executed with nothing returned." ),
93+ PSQLState .NO_DATA );
94+ }
9695
97- ResultSet rs = castNonNull (getResultSet ());
98- if (!rs .next ()) {
99- throw new PSQLException (GT .tr ("A CallableStatement was executed with nothing returned." ),
100- PSQLState .NO_DATA );
101- }
96+ ResultSet rs = castNonNull (getResultSet ());
97+ if (!rs .next ()) {
98+ throw new PSQLException (GT .tr ("A CallableStatement was executed with nothing returned." ),
99+ PSQLState .NO_DATA );
100+ }
102101
103- // figure out how many columns
104- int cols = rs .getMetaData ().getColumnCount ();
102+ // figure out how many columns
103+ int cols = rs .getMetaData ().getColumnCount ();
105104
106- int outParameterCount = preparedParameters .getOutParameterCount ();
105+ int outParameterCount = preparedParameters .getOutParameterCount ();
107106
108- if (cols != outParameterCount ) {
109- throw new PSQLException (
110- GT .tr ("A CallableStatement was executed with an invalid number of parameters" ),
111- PSQLState .SYNTAX_ERROR );
107+ if (cols != outParameterCount ) {
108+ throw new PSQLException (
109+ GT .tr ("A CallableStatement was executed with an invalid number of parameters" ),
110+ PSQLState .SYNTAX_ERROR );
111+ }
112+
113+ // reset last result fetched (for wasNull)
114+ lastIndex = 0 ;
115+
116+ // allocate enough space for all possible parameters without regard to in/out
117+ @ Nullable Object [] callResult = new Object [preparedParameters .getParameterCount () + 1 ];
118+ this .callResult = callResult ;
119+
120+ // move them into the result set
121+ for (int i = 0 , j = 0 ; i < cols ; i ++, j ++) {
122+ // find the next out parameter, the assumption is that the functionReturnType
123+ // array will be initialized with 0 and only out parameters will have values
124+ // other than 0. 0 is the value for java.sql.Types.NULL, which should not
125+ // conflict
126+ while (j < functionReturnType .length && functionReturnType [j ] == 0 ) {
127+ j ++;
112128 }
113129
114- // reset last result fetched (for wasNull)
115- lastIndex = 0 ;
116-
117- // allocate enough space for all possible parameters without regard to in/out
118- @ Nullable Object [] callResult = new Object [preparedParameters .getParameterCount () + 1 ];
119- this .callResult = callResult ;
120-
121- // move them into the result set
122- for (int i = 0 , j = 0 ; i < cols ; i ++, j ++) {
123- // find the next out parameter, the assumption is that the functionReturnType
124- // array will be initialized with 0 and only out parameters will have values
125- // other than 0. 0 is the value for java.sql.Types.NULL, which should not
126- // conflict
127- while (j < functionReturnType .length && functionReturnType [j ] == 0 ) {
128- j ++;
129- }
130+ callResult [j ] = rs .getObject (i + 1 );
131+ int columnType = rs .getMetaData ().getColumnType (i + 1 );
130132
131- callResult [j ] = rs .getObject (i + 1 );
132- int columnType = rs .getMetaData ().getColumnType (i + 1 );
133-
134- if (columnType != functionReturnType [j ]) {
135- // this is here for the sole purpose of passing the cts
136- if (columnType == Types .DOUBLE && functionReturnType [j ] == Types .REAL ) {
137- // return it as a float
138- Object result = callResult [j ];
139- if (result != null ) {
140- callResult [j ] = ((Double ) result ).floatValue ();
141- }
142- } else if (columnType == Types .REF_CURSOR && functionReturnType [j ] == Types .OTHER ) {
143- // For backwards compatibility reasons we support that ref cursors can be
144- // registered with both Types.OTHER and Types.REF_CURSOR so we allow
145- // this specific mismatch
146- } else {
147- throw new PSQLException (GT .tr (
148- "A CallableStatement function was executed and the out parameter {0} was of type {1} however type {2} was registered." ,
149- i + 1 , "java.sql.Types=" + columnType , "java.sql.Types=" + functionReturnType [j ]),
150- PSQLState .DATA_TYPE_MISMATCH );
133+ if (columnType != functionReturnType [j ]) {
134+ // this is here for the sole purpose of passing the cts
135+ if (columnType == Types .DOUBLE && functionReturnType [j ] == Types .REAL ) {
136+ // return it as a float
137+ Object result = callResult [j ];
138+ if (result != null ) {
139+ callResult [j ] = ((Double ) result ).floatValue ();
151140 }
141+ } else if (columnType == Types .REF_CURSOR && functionReturnType [j ] == Types .OTHER ) {
142+ // For backwards compatibility reasons we support that ref cursors can be
143+ // registered with both Types.OTHER and Types.REF_CURSOR so we allow
144+ // this specific mismatch
145+ } else {
146+ throw new PSQLException (GT .tr (
147+ "A CallableStatement function was executed and the out parameter {0} was of type {1} however type {2} was registered." ,
148+ i + 1 , "java.sql.Types=" + columnType , "java.sql.Types=" + functionReturnType [j ]),
149+ PSQLState .DATA_TYPE_MISMATCH );
152150 }
153-
154151 }
155- rs .close ();
152+
153+ }
154+ rs .close ();
155+ synchronized (this ) {
156156 result = null ;
157157 }
158158 return false ;
0 commit comments