Skip to content

Instantly share code, notes, and snippets.

View wmuron's full-sized avatar

Wiktor Muroń wmuron

View GitHub Profile
@wmuron
wmuron / User.hbm.xml
Created October 20, 2016 13:32
HBM mapping file for DbAssist article
<hibernate-mapping>
<class name="com.montrosesoftware.dbassist.User" table="users">
<id name="id" type="integer">
<column name="id" />
</id>
<property name="name" type="string" length="100" column="name"/>
<property name="createdAtUtc" type="timestamp" column="created_at_utc"/>
</class>
</hibernate-mapping>
@wmuron
wmuron / User.java
Created October 20, 2016 13:31
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) {
this.id = id;
this.name = 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();