Skip to content

Instantly share code, notes, and snippets.

Avatar

Wiktor Muron wmuron

  • Nauto
  • Cracow/Palo Alto
View GitHub Profile
@wmuron
wmuron / User.hbm.xml
Created Oct 20, 2016
HBM mapping file for DbAssist article
View User.hbm.xml
<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 Oct 20, 2016
Entity for DbAssist article
View User.java
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;
}
View ReadDateZeroWithJDBC.java
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();
You can’t perform that action at this time.