For IntelliJ IDEA and
Android Studio


private void myMethod () {PreparedStatement p =
Connection connection;connection.prepareStatement(sql)
Connection connection;connection.prepareStatement(sql, autoGeneratedKeys)
Connection connection;connection.prepareStatement(sql, resultSetType, resultSetConcurrency)
- AI code suggestions by Codota
}
final PreparedStatement statement = connection.prepareStatement( "SELECT my_column FROM my_table where search_column = ANY (?)" ); final String[] values = getValues(); statement.setArray(1, connection.createArrayOf("text", values)); final ResultSet rs = statement.executeQuery(); try { while(rs.next()) { // do some... } } finally { rs.close(); }
public void setArray(int parameterIndex, Array x) throws SQLException { try { if (this.wrappedStmt != null) { ((PreparedStatement) this.wrappedStmt).setArray(parameterIndex, x); } else { throw SQLError.createSQLException(Messages.getString("Statement.AlreadyClosed"), SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor); } } catch (SQLException sqlEx) { checkAndFireConnectionError(sqlEx); } }
statement.setTimestamp(i + 1, (Timestamp) param); } else if (param instanceof Array) { statement.setArray(i + 1, (Array) param); } else {
public void setArray(int i, Array x) throws SQLException { checkOpen(); try { ((PreparedStatement)_stmt).setArray(i,x); } catch (SQLException e) { handleException(e); } }
String[] insertvalues = { "a", "b", "c" }; PreparedStatement p = conn.prepareStatement("INSERT INTO my_table VALUES( ? )"); ARRAY insertParameter = new ARRAY( a_desc, conn, insertvalues ); p.setArray( 1, insertParameter ); p.execute();
ArrayList<String> list = new ArrayList<String>(); PreparedStatement pstmt = conn.prepareStatement("select * from employee where id in (?)"); Array array = conn.createArrayOf("VARCHAR", list.toArray()); pstmt.setArray(1, array); ResultSet rs = pstmt.executeQuery();
public void setArray(final int i, final Array x) throws SQLException { try { original.setArray(i, x); } catch (final SQLException e) { throw wrapException(e); } }
private void upsertData(PreparedStatement stmt, String name, int year, Double[] data) throws SQLException { int i = 1; stmt.setString(i++, name); stmt.setInt(i++, year); Array recordings = new PhoenixArray.PrimitiveDoublePhoenixArray(PDouble.INSTANCE, data); stmt.setArray(i++, recordings); stmt.execute(); }
/** * Helper method to create a {@link Array} for a specific {@link PDataType}, and set it on * the provided {@code stmt}. */ private static void setArrayInStatement(PreparedStatement stmt, PDataType<?> type, Object[] obj, int position) throws SQLException { Array sqlArray = stmt.getConnection().createArrayOf( PDataType.arrayBaseType(type).getSqlTypeName(), obj); stmt.setArray(position, sqlArray); }
PreparedStatement stmt = connection.prepareStatement( "DECLARE " + " records SYS_REFCURSOR; " + "BEGIN " + " OPEN records FOR " + " SELECT * FROM TABLE(?); " + " my_proc(records); " + "END;"); // Set the records as an array stmt.setArray(1, records);
@Override protected void doSetValue(PreparedStatement preparedStatement, int index, Array value) throws SQLException { preparedStatement.setArray(index, value); }
PreparedStatement pstmt = conn.prepareStatement("select * from employee where id in (?)"); Array array = conn.createArrayOf("VARCHAR", new Object[]{"1", "2","3"}); pstmt.setArray(1, array); ResultSet rs = pstmt.executeQuery();
final PreparedStatement statement = connection.prepareStatement( "SELECT my_column FROM my_table " + "where search_column IN (SELECT * FROM unnest(?))" ); final String[] values = getValues(); statement.setArray(1, connection.createArrayOf("text", values)); final ResultSet rs = statement.executeQuery(); try { while(rs.next()) { // do some... } } finally { rs.close(); }
Object[] arrayObject = { x, y }; ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor( "MY_SCHEMA.MY_ARRAY_TYPE", conn); ARRAY myArray = new ARRAY(descriptor, conn, arrayObject); CallableStatement cs = conn .prepareCall("{ call package1.procedure1(?)}"); cs.setArray(1, myArray); cs.execute(); conn.close();
@Override public void run() throws Exception { stmt.setArray(1, null); } });