Java tutorial
//package com.java2s; import java.sql.*; public class Main { public static PreparedStatement createFieldsInsert(Connection conn, int layerId, String name, String description, String fieldId, String fieldType, String sid, String sname, String sdesc, boolean indb, boolean enabled, boolean namesearch, boolean defaultlayer, boolean intersect, boolean layerbranch, boolean analysis, boolean addToMap) throws SQLException { // TOOD slightly different statement if sdesc is null... PreparedStatement stFieldsInsert = conn.prepareStatement( "INSERT INTO fields (name, id, \"desc\", type, spid, sid, sname, sdesc, indb, enabled, last_update, namesearch, defaultlayer, \"intersect\", layerbranch, analysis, addtomap)" + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"); stFieldsInsert.setString(1, name); stFieldsInsert.setString(2, fieldId); stFieldsInsert.setString(3, description); stFieldsInsert.setString(4, fieldType); stFieldsInsert.setString(5, Integer.toString(layerId)); stFieldsInsert.setString(6, sid); stFieldsInsert.setString(7, sname); if (sdesc == null || sdesc.isEmpty()) { stFieldsInsert.setNull(8, Types.VARCHAR); } else { stFieldsInsert.setString(8, sdesc); } stFieldsInsert.setBoolean(9, indb); stFieldsInsert.setBoolean(10, enabled); stFieldsInsert.setTimestamp(11, new Timestamp(System.currentTimeMillis())); stFieldsInsert.setBoolean(12, namesearch); stFieldsInsert.setBoolean(13, defaultlayer); stFieldsInsert.setBoolean(14, intersect); stFieldsInsert.setBoolean(15, layerbranch); stFieldsInsert.setBoolean(16, analysis); stFieldsInsert.setBoolean(17, addToMap); return stFieldsInsert; } }