Java Utililty Methods SQL PreparedStatement

List of utility methods to do SQL PreparedStatement

Description

The list of methods to do SQL PreparedStatement are organized into topic(s).

Method

voidsetValue(PreparedStatement ps, int paramIndex, Object inValue)
set Value
setValue(ps, paramIndex, 2, inValue);
booleansetValue(PreparedStatement ps, int posicion, int tipo, String strDefault, String strValor)
set Value
try {
    if (strValor == null) {
        strValor = strDefault;
    if (strValor != null) {
        if (strValor.compareTo("") == 0)
            ps.setNull(posicion, tipo);
        else {
...
voidsetValueIndex(PreparedStatement stmt, int index, int valueIndex)
set Value Index
stmt.setInt(index, valueIndex);
voidsetValues(PreparedStatement preparedStatement, Object... values)
See comments on #preparePlaceHolders(int)
for (int i = 0; i < values.length; i++) {
    preparedStatement.setObject(i + 1, values[i]);
booleansetValues(PreparedStatement statement, Object... values)
set Values
if (values != null) {
    for (int i = 0; i < values.length; ++i) {
        try {
            statement.setObject(i, values[i]);
        } catch (SQLException e) {
            return false;
return true;
voidsetValues(PreparedStatement statement, Object... values)
Set the given parameter values in the given PreparedStatement.
for (int i = 0; i < values.length; i++) {
    statement.setObject(i + 1, values[i]);
voidsetValues(PreparedStatement statement, Object[] values)
set Values
for (int i = 0; i < values.length; i++) {
    statement.setObject(i + 1, values[i]);
voidsubstitute(PreparedStatement stmt, Object[] params)
Substitute prepared stmt query parameters
for (int i = 0; i < params.length; ++i) {
    stmt.setObject(i + 1, params[i]);
voidwriteArray(Connection connection, PreparedStatement preparedStatement, int column, Class type, T[] array)
write Array
if (type == String.class) {
    java.sql.Array sqlArray = connection.createArrayOf("VARCHAR", array);
    preparedStatement.setArray(column, sqlArray);
} else {
    throw new IllegalArgumentException("Type '" + type.getName() + "' is not supported.");
voidwriteList(Connection connection, PreparedStatement preparedStatement, int column, Class type, List list)
write List
@SuppressWarnings("unchecked")
T[] array = (T[]) list.toArray();
writeArray(connection, preparedStatement, column, type, array);