Here you can find the source of writeList(Connection connection, PreparedStatement preparedStatement, int column, Class
public static <T> void writeList(Connection connection, PreparedStatement preparedStatement, int column, Class<T> type, List<T> list) throws SQLException
//package com.java2s; //License from project: Open Source License import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.List; public class Main { public static <T> void writeList(Connection connection, PreparedStatement preparedStatement, int column, Class<T> type, List<T> list) throws SQLException { @SuppressWarnings("unchecked") T[] array = (T[]) list.toArray(); writeArray(connection, preparedStatement, column, type, array); }/*from w w w .j av a2 s . co m*/ 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 { throw new IllegalArgumentException("Type '" + type.getName() + "' is not supported."); } } }