Java SQL PreparedStatement writeArray(Connection connection, PreparedStatement preparedStatement, int column, Class type, T[] array)

Here you can find the source of writeArray(Connection connection, PreparedStatement preparedStatement, int column, Class type, T[] array)

Description

write Array

License

Open Source License

Declaration

public static <T> void writeArray(Connection connection, PreparedStatement preparedStatement, int column,
            Class<T> type, T[] array) throws SQLException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.SQLException;

public class Main {
    public static <T> void writeArray(Connection connection, PreparedStatement preparedStatement, int column,
            Class<T> type, T[] array) throws SQLException {
        if (type == String.class) {
            java.sql.Array sqlArray = connection.createArrayOf("VARCHAR", array);
            preparedStatement.setArray(column, sqlArray);
        } else {/*from w  w w .j  a  v a 2 s  .co  m*/
            throw new IllegalArgumentException("Type '" + type.getName() + "' is not supported.");
        }
    }
}

Related

  1. setValues(PreparedStatement preparedStatement, Object... values)
  2. setValues(PreparedStatement statement, Object... values)
  3. setValues(PreparedStatement statement, Object... values)
  4. setValues(PreparedStatement statement, Object[] values)
  5. substitute(PreparedStatement stmt, Object[] params)
  6. writeList(Connection connection, PreparedStatement preparedStatement, int column, Class type, List list)
  7. writeMap(Connection connection, PreparedStatement preparedStatement, int keyColumn, int valueColumn, Class keyType, Class valueType, Map map)
  8. writeProperties(Connection connection, PreparedStatement preparedStatement, int keyColumn, int valueColumn, Properties properties)