PreparedStatement.setArray
Code IndexAdd Codota to your IDE (free)

Best code snippets using java.sql.PreparedStatement.setArray(Showing top 15 results out of 720)

  • Common ways to obtain PreparedStatement
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
}
origin: stackoverflow.com

 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();
}
origin: mysql/mysql-connector-java

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);
  }
}
origin: apache/flink

  statement.setTimestamp(i + 1, (Timestamp) param);
} else if (param instanceof Array) {
  statement.setArray(i + 1, (Array) param);
} else {
origin: commons-dbcp/commons-dbcp

public void setArray(int i, Array x) throws SQLException
{ checkOpen(); try { ((PreparedStatement)_stmt).setArray(i,x); } catch (SQLException e) { handleException(e); } }
origin: stackoverflow.com

 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();
origin: stackoverflow.com

 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();
origin: org.seasar.container/s2-extension

public void setArray(final int i, final Array x) throws SQLException {
  try {
    original.setArray(i, x);
  } catch (final SQLException e) {
    throw wrapException(e);
  }
}
origin: apache/phoenix

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();
}
origin: apache/phoenix

/**
 * 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);
}
origin: stackoverflow.com

 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);
origin: org.seasar.doma/doma

@Override
protected void doSetValue(PreparedStatement preparedStatement, int index,
    Array value) throws SQLException {
  preparedStatement.setArray(index, value);
}
origin: stackoverflow.com

 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();
origin: stackoverflow.com

 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();
}
origin: stackoverflow.com

 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();
origin: apache/ignite

  @Override public void run() throws Exception {
    stmt.setArray(1, null);
  }
});
java.sqlPreparedStatementsetArray

Javadoc

Sets the designated parameter to the given java.sql.Array object. The driver converts this to an SQL ARRAY value when it sends it to the database.

Popular methods of PreparedStatement

  • executeQuery
  • setString
    Sets the value of a specified parameter to a supplied string.
  • executeUpdate
  • close
  • setInt
    Sets the value of a specified parameter to a supplied int value.
  • execute
  • setObject
  • setLong
    Sets the value of a specified parameter to a supplied long value.
  • setNull
    Sets the value of a specified parameter to SQL NULL. This version of setNull should be used for User
  • addBatch
  • setTimestamp
    Sets the value of a specified parameter to a supplied java.sql.Timestamp value, using the supplied C
  • executeBatch
  • setTimestamp,
  • executeBatch,
  • setBytes,
  • setBoolean,
  • setDate,
  • setDouble,
  • setBinaryStream,
  • getGeneratedKeys,
  • setBigDecimal,
  • setTime

Popular classes and methods

  • setScale (BigDecimal)
    Returns a new BigDecimal instance with the specified scale. If the new scale is greater than the old
  • requestLocationUpdates (LocationManager)
  • getContentResolver (Context)
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • TimerTask (java.util)
    A task that can be scheduled for one-time or repeated execution by a Timer.
  • ImageIO (javax.imageio)
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Join (org.hibernate.mapping)

For IntelliJ IDEA and
Android Studio

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)