use of java.sql.Time in project querydsl by querydsl.
the class AbstractMapperTest method setUp.
@Before
public void setUp() {
employee = new Employee();
employee.setDatefield(new Date(0));
employee.setFirstname("A");
employee.setLastname("B");
employee.setSalary(new BigDecimal(1.0));
employee.setSuperiorId(2);
employee.setTimefield(new Time(0));
}
use of java.sql.Time in project querydsl by querydsl.
the class JSR310LocalTimeTypeTest method jodaSet.
@Test
public void jodaSet() throws SQLException {
LocalTime value = LocalTime.now();
Time time = new Time(value.get(ChronoField.MILLI_OF_DAY));
PreparedStatement stmt = EasyMock.createNiceMock(PreparedStatement.class);
stmt.setTime(1, time, UTC);
EasyMock.replay(stmt);
new LocalTimeType().setValue(stmt, 1, toJoda(value));
EasyMock.verify(stmt);
}
use of java.sql.Time in project querydsl by querydsl.
the class JSR310OffsetTimeTypeTest method get.
@Test
public void get() throws SQLException {
ResultSet resultSet = EasyMock.createNiceMock(ResultSet.class);
EasyMock.expect(resultSet.getTime(1, UTC)).andReturn(new Time(UTC.getTimeInMillis()));
EasyMock.replay(resultSet);
OffsetTime result = type.getValue(resultSet, 1);
EasyMock.verify(resultSet);
assertNotNull(result);
assertTrue(result.getSecond() == 0);
}
use of java.sql.Time in project robovm by robovm.
the class SelectFunctionalityTest method createTestTables.
private void createTestTables() {
try {
ResultSet userTab = conn.getMetaData().getTables(null, null, null, null);
while (userTab.next()) {
String tableName = userTab.getString("TABLE_NAME");
if (tableName.equals(DatabaseCreator.TEST_TABLE2)) {
statement.execute(DatabaseCreator.DROP_TABLE2);
} else if (tableName.equals(DatabaseCreator.SALESPEOPLE_TABLE)) {
statement.execute(DatabaseCreator.DROP_TABLE_SALESPEOPLE);
} else if (tableName.equals(DatabaseCreator.CUSTOMERS_TABLE)) {
statement.execute(DatabaseCreator.DROP_TABLE_CUSTOMERS);
} else if (tableName.equals(DatabaseCreator.ORDERS_TABLE)) {
statement.execute(DatabaseCreator.DROP_TABLE_ORDERS);
}
}
userTab.close();
statement.execute(DatabaseCreator.CREATE_TABLE2);
statement.execute(DatabaseCreator.CREATE_TABLE_SALESPEOPLE);
statement.execute(DatabaseCreator.CREATE_TABLE_CUSTOMERS);
statement.execute(DatabaseCreator.CREATE_TABLE_ORDERS);
long currentTime = Calendar.getInstance().getTimeInMillis();
date = new Date(currentTime);
time = new Time(currentTime);
DatabaseCreator.fillTestTable2(conn, 1, 5, currentTime);
DatabaseCreator.fillCustomersTable(conn);
DatabaseCreator.fillOrdersTable(conn);
DatabaseCreator.fillSalesPeopleTable(conn);
} catch (SQLException e) {
fail("Unexpected SQLException " + e.toString());
}
}
use of java.sql.Time in project robovm by robovm.
the class DatabaseCreator method fillTestTable2.
public static void fillTestTable2(Connection conn, int startID, int endID, long time) throws SQLException {
Statement statement = conn.createStatement();
for (int id = startID; id <= endID; id++) {
double value = id + DatabaseCreator.defaultDouble;
String insertQuery = "INSERT INTO " + DatabaseCreator.TEST_TABLE2 + " (finteger, ftext, fcharacter, fdecimal, fnumeric," + " fsmallint, ffloat, freal, fdouble, fdate, ftime)" + " VALUES (" + id + ", '" + DatabaseCreator.defaultString + id + "'," + " '" + DatabaseCreator.defaultCharacter + id + "', " + value + ", " + value + "," + value + ", " + value + ", " + value + "," + value + ", '" + new Date(time).toString() + "'," + " '" + new Time(time).toString() + "')";
statement.execute(insertQuery);
}
}
Aggregations