@Override public int getInt(String parameterName) throws SQLException { return delegate.getInt(parameterName); }
@Override public int getInt(int parameterIndex) throws SQLException { return delegate.getInt(parameterIndex); }
public int getInt(int parameterIndex) throws SQLException { return cstmt.getInt(parameterIndex); }
public int getInt(String parameterName) throws SQLException { return cstmt.getInt(parameterName); }
@Override public int getInt(int parameterIndex) throws SQLException { try { return stmt.getInt(parameterIndex); } catch (Throwable t) { throw checkException(t); } }
@Override public int getInt(String parameterName) throws SQLException { try { return stmt.getInt(parameterName); } catch (Throwable t) { throw checkException(t); } }
CallableStatement proc = connection.prepareCall("{ ? = call dbo.mySproc() }"); proc.registerOutParameter(1, Types.INTEGER); proc.execute(); int returnValue = proc.getInt(1);
String sql = "BEGIN INSERT INTO mytable(id, content) VALUES (seq_mytable.NEXTVAL(), ?) RETURNING id INTO ?; END;"; Connection connection = null; CallableStatement statement = null; try { connection = database.getConnection(); statement = connection.prepareCall(sql); statement.setString(1, "test"); statement.registerOutParameter(2, Types.NUMERIC); statement.execute(); int id = statement.getInt(2); // ...
session.doWork(new Work() { public void execute(Connection connection) throws SQLException { CallableStatement call = connection.prepareCall("{ ? = call MYSCHEMA.MYFUNC(?,?) }"); call.registerOutParameter( 1, Types.INTEGER ); // or whatever it is call.setLong(2, id); call.setLong(3, transId); call.execute(); int result = call.getInt(1); // propagate this back to enclosing class } });
@Override protected X doExtract(CallableStatement statement, String name, WrapperOptions options) throws SQLException { return javaTypeDescriptor.wrap( statement.getInt( name ), options ); } };
public int getInteger(final int index) { try { return statement.getInt(index); } catch (SQLException sex) { throw newGetParamError(index, sex); } }
@Override protected X doExtract(CallableStatement statement, int index, WrapperOptions options) throws SQLException { return javaTypeDescriptor.wrap( statement.getInt( index ), options ); }
@Override public int callableStatement_getInt(CallableStatementProxy statement, int parameterIndex) throws SQLException { if (this.pos < filterSize) { return nextFilter().callableStatement_getInt(this, statement, parameterIndex); } return statement.getRawObject().getInt(parameterIndex); }
@Override public int callableStatement_getInt(CallableStatementProxy statement, String parameterName) throws SQLException { if (this.pos < filterSize) { return nextFilter().callableStatement_getInt(this, statement, parameterName); } return statement.getRawObject().getInt(parameterName); }
public int[] getAllInteger(final String param) { final int[] positions = query.getNamedParameterIndices(param); final int[] result = new int[positions.length]; try { for (int i = 0; i < positions.length; i++) { result[i] = statement.getInt(positions[i]); } return result; } catch (SQLException sex) { throw newGetParamError(param, sex); } }
@Override public T getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { int i = cs.getInt(columnIndex); if (cs.wasNull()) { return null; } else { return locateEnumIntegerValue(i); } }
@Override protected int determineRowCount(int reportedRowCount, PreparedStatement statement) { try { return toCallableStatement( statement ).getInt( parameterPosition ); } catch (SQLException sqle) { sqlExceptionHelper.logExceptions( sqle, "could not extract row counts from CallableStatement" ); throw new GenericJDBCException( "could not extract row counts from CallableStatement", sqle ); } }
public int getInteger(final String param) { final int[] positions = query.getNamedParameterIndices(param); try { if (positions.length == 1) { return statement.getInt(positions[0]); } throw newGetParamError(param); } catch (SQLException sex) { throw newGetParamError(param, sex); } }
@Test public void testFunctionWithJDBC() { doInJPA( this::entityManagerFactory, entityManager -> { //tag::sql-call-function-mysql-example[] final AtomicReference<Integer> phoneCount = new AtomicReference<>(); Session session = entityManager.unwrap( Session.class ); session.doWork( connection -> { try (CallableStatement function = connection.prepareCall( "{ ? = call fn_count_phones(?) }" )) { function.registerOutParameter( 1, Types.INTEGER ); function.setInt( 2, 1 ); function.execute(); phoneCount.set( function.getInt( 1 ) ); } } ); //end::sql-call-function-mysql-example[] assertEquals(Integer.valueOf(2), phoneCount.get()); }); } }
@Test public void testStoredProcedureReturnValue() { doInJPA( this::entityManagerFactory, entityManager -> { Session session = entityManager.unwrap( Session.class ); session.doWork( connection -> { CallableStatement function = null; try { function = connection.prepareCall("{ ? = call fn_count_phones(?) }"); function.registerOutParameter(1, Types.INTEGER); function.setInt(2, 1); function.execute(); int phoneCount = function.getInt(1); assertEquals(2, phoneCount); } finally { if ( function != null ) { function.close(); } } } ); } ); } }