Search in sources :

Example 71 with Timestamp

use of java.sql.Timestamp in project querydsl by querydsl.

the class JSR310InstantTypeTest method set.

@Test
public void set() throws SQLException {
    Instant value = Instant.now();
    Timestamp ts = new Timestamp(value.toEpochMilli());
    PreparedStatement stmt = EasyMock.createNiceMock(PreparedStatement.class);
    stmt.setTimestamp(1, ts, UTC);
    EasyMock.replay(stmt);
    type.setValue(stmt, 1, value);
    EasyMock.verify(stmt);
}
Also used : Instant(java.time.Instant) PreparedStatement(java.sql.PreparedStatement) Timestamp(java.sql.Timestamp) Test(org.junit.Test)

Example 72 with Timestamp

use of java.sql.Timestamp in project querydsl by querydsl.

the class JSR310InstantTypeTest method jodaSet.

@Test
public void jodaSet() throws SQLException {
    Instant value = Instant.now();
    Timestamp ts = new Timestamp(value.toEpochMilli());
    PreparedStatement stmt = EasyMock.createNiceMock(PreparedStatement.class);
    stmt.setTimestamp(1, ts);
    EasyMock.replay(stmt);
    new DateTimeType().setValue(stmt, 1, toJoda(value));
    EasyMock.verify(stmt);
}
Also used : Instant(java.time.Instant) PreparedStatement(java.sql.PreparedStatement) Timestamp(java.sql.Timestamp) Test(org.junit.Test)

Example 73 with Timestamp

use of java.sql.Timestamp in project querydsl by querydsl.

the class JSR310OffsetDateTimeTypeTest method get.

@Test
public void get() throws SQLException {
    ResultSet resultSet = EasyMock.createNiceMock(ResultSet.class);
    EasyMock.expect(resultSet.getTimestamp(1, UTC)).andReturn(new Timestamp(UTC.getTimeInMillis()));
    EasyMock.replay(resultSet);
    OffsetDateTime result = type.getValue(resultSet, 1);
    EasyMock.verify(resultSet);
    assertNotNull(result);
    assertTrue(result.toEpochSecond() == 0);
}
Also used : OffsetDateTime(java.time.OffsetDateTime) ResultSet(java.sql.ResultSet) Timestamp(java.sql.Timestamp) Test(org.junit.Test)

Example 74 with Timestamp

use of java.sql.Timestamp in project querydsl by querydsl.

the class JSR310ZonedDateTimeTypeTest method set.

@Test
public void set() throws SQLException {
    ZonedDateTime value = ZonedDateTime.now();
    Timestamp ts = new Timestamp(value.toInstant().toEpochMilli());
    PreparedStatement stmt = EasyMock.createNiceMock(PreparedStatement.class);
    stmt.setTimestamp(1, ts, UTC);
    EasyMock.replay(stmt);
    type.setValue(stmt, 1, value);
    EasyMock.verify(stmt);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) PreparedStatement(java.sql.PreparedStatement) Timestamp(java.sql.Timestamp) Test(org.junit.Test)

Example 75 with Timestamp

use of java.sql.Timestamp in project jforum2 by rafaelsteil.

the class GenericForumDAO method checkUnreadTopics.

/**
	 * @see net.jforum.dao.ForumDAO#hasUnreadTopics(int, long)
	 */
public List checkUnreadTopics(int forumId, long lastVisit) {
    List l = new ArrayList();
    PreparedStatement p = null;
    ResultSet rs = null;
    try {
        p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("ForumModel.checkUnreadTopics"));
        p.setInt(1, forumId);
        p.setTimestamp(2, new Timestamp(lastVisit));
        rs = p.executeQuery();
        while (rs.next()) {
            Topic t = new Topic();
            t.setId(rs.getInt("topic_id"));
            t.setTime(new Date(rs.getTimestamp(1).getTime()));
            l.add(t);
        }
        return l;
    } catch (SQLException e) {
        throw new DatabaseException(e);
    } finally {
        DbUtils.close(rs, p);
    }
}
Also used : SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) List(java.util.List) PreparedStatement(java.sql.PreparedStatement) Topic(net.jforum.entities.Topic) Timestamp(java.sql.Timestamp) DatabaseException(net.jforum.exceptions.DatabaseException) Date(java.util.Date)

Aggregations

Timestamp (java.sql.Timestamp)1539 PreparedStatement (java.sql.PreparedStatement)265 Test (org.junit.Test)245 SQLException (java.sql.SQLException)236 ResultSet (java.sql.ResultSet)209 BigDecimal (java.math.BigDecimal)204 Date (java.util.Date)165 Date (java.sql.Date)122 Connection (java.sql.Connection)117 ArrayList (java.util.ArrayList)109 Calendar (java.util.Calendar)76 Test (org.testng.annotations.Test)71 GregorianCalendar (java.util.GregorianCalendar)68 Time (java.sql.Time)65 SimpleDateFormat (java.text.SimpleDateFormat)62 Change (com.google.gerrit.reviewdb.client.Change)59 IOException (java.io.IOException)51 BaseTest (util.BaseTest)49 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)45 Properties (java.util.Properties)41