import java.sql.*; public class MySQL5147NPEBug { public static void main(String[] args) throws Exception { Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/SomeDb?user=SomeUser&password=SomePassword&characterEncoding=UTF-8"); PreparedStatement stmt = conn.prepareStatement( "insert into MySQL5147NPEBug (groupId, messagingTime, eventTime, expireTime) values (?,?,?,?)" ); ParameterMetaData data = stmt.getParameterMetaData(); stmt.setString(1, "my group id"); stmt.setTimestamp(2, new Timestamp(System.currentTimeMillis())); stmt.setTimestamp(3, new Timestamp(System.currentTimeMillis())); stmt.setTimestamp(4, new Timestamp(System.currentTimeMillis())); stmt.executeUpdate(); } }