import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Statement; import java.util.Calendar; public class ConnectorJBug100294 { public static void main(String[] args) { Statement stmt = null; Connection conn = null; PreparedStatement pStmt = null; try { conn = DriverManager.getConnection("jdbc:mysql://localhost/test?" + "useServerPrepStmts=true&user=root&password="); stmt = conn.createStatement(); stmt.execute("CREATE TABLE IF NOT EXISTS datetest (date Date)"); stmt.close(); stmt = null; pStmt = conn.prepareStatement("INSERT INTO datetest (date) VALUES(?)"); pStmt.setDate(1, new java.sql.Date(Calendar.getInstance().getTimeInMillis())); pStmt.addBatch(); pStmt.executeBatch(); pStmt.close(); pStmt = null; } catch (SQLException ex) { ex.printStackTrace(); } finally { if (stmt != null) { try { stmt.close(); } catch (SQLException sqlEx) { // ignore } stmt = null; } if (pStmt != null) { try { pStmt.close(); } catch (SQLException sqlEx) { // ignore } pStmt = null; } if (conn != null) { try { conn.close(); } catch (SQLException ex) { // ignore } conn = null; } } } }