Skip to content

Instantly share code, notes, and snippets.


Wiktor Muron wmuron

View GitHub Profile
wmuron / User.hbm.xml
Created Oct 20, 2016
HBM mapping file for DbAssist article
View User.hbm.xml
<class name="com.montrosesoftware.dbassist.User" table="users">
<id name="id" type="integer">
<column name="id" />
<property name="name" type="string" length="100" column="name"/>
<property name="createdAtUtc" type="timestamp" column="created_at_utc"/>
wmuron /
Created Oct 20, 2016
Entity for DbAssist article
public class User {
private int id;
private String name;
private java.util.Date createdAtUtc;
public User(int id, String name, java.util.Date createdAtUtc) { = id; = name;
this.createdAtUtc = createdAtUtc;
public class ReadDateZeroWithJDBC {
public static void main(String args[]) throws ClassNotFoundException, SQLException {
Connection conn = setupJDBCAndConnect();
//expected epoch unix time
java.util.Date dateExpected = new java.util.Date(0);
//actual created_at_utc from the user record in DB
PreparedStatement stmtRead = createSelectStatement(conn, 1);
ResultSet rs = stmtRead.executeQuery();