Java examples for java.sql:PreparedStatement
Sets the parameter in the PreparedStatement with a time value, or null if the Calendar is null.
//package com.java2s; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Types; import java.util.Calendar; public class Main { /**/*from w w w . j ava 2 s .com*/ * Sets the parameter in the statement with a time value, or null if * the Calendar is null. * @param stmt The statement in which the parameter value is to be set. * @param paramIndex The index of the parameter to set. * @param cal The value to set (or null). * @throws SQLException Indicates an error setting the parameter. */ public static void setNullableTime(PreparedStatement stmt, int paramIndex, Calendar cal) throws SQLException { if (cal == null) { stmt.setNull(paramIndex, Types.TIME); } else { stmt.setTime(paramIndex, new java.sql.Time(cal.getTime() .getTime())); } } }