Here you can find the source of writeProperties(Connection connection, PreparedStatement preparedStatement, int keyColumn, int valueColumn, Properties properties)
public static void writeProperties(Connection connection, PreparedStatement preparedStatement, int keyColumn, int valueColumn, Properties properties) 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.ArrayList; import java.util.List; import java.util.Properties; public class Main { public static void writeProperties(Connection connection, PreparedStatement preparedStatement, int keyColumn, int valueColumn, Properties properties) throws SQLException { List<Object> keys = new ArrayList<>(properties.keySet()); List<Object> values = new ArrayList<>(); for (Object key : keys) { values.add(properties.get(key)); }/*from w w w . j ava 2 s .com*/ writeArray(connection, preparedStatement, keyColumn, Object.class, keys.toArray()); writeArray(connection, preparedStatement, valueColumn, Object.class, values.toArray()); } 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."); } } }