Java tutorial
//package com.java2s; //License from project: Open Source License import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Types; public class Main { /** * Sets the optional string. * * @param statement the statement * @param string the string * @param optionIndex the option index * @return the prepared statement * @throws SQLException the sQL exception */ static PreparedStatement setOptionalString(PreparedStatement statement, String string, int optionIndex) throws SQLException { if (string != null) statement.setString(optionIndex, string); else statement.setNull(optionIndex, Types.VARCHAR); return statement; } }