297 Statement statement = m_conn.createStatement();
298 TimeZone.setDefault(TimeZone.getTimeZone(
"GMT"));
301 String d_ceiling =
"select {fn ceiling(1.005)} as YYY";
302 ResultSet rs = statement.executeQuery(d_ceiling);
303 for (
int i = 0; rs.next(); ++i) {
304 float yyy = rs.getFloat(
"YYY");
305 assertEquals(
Float.compare(2.0F, yyy), 0);
309 String d_floor =
"select {fn floor(1.005)} as YYY";
310 rs = statement.executeQuery(d_floor);
311 for (
int i = 0; rs.next(); ++i) {
312 float yyy = rs.getFloat(
"YYY");
313 assertEquals(
Float.compare(1.0F, yyy), 0);
317 String d_ln =
"select {fn log(10)} as m_ln";
318 rs = statement.executeQuery(d_ln);
319 for (
int i = 0; rs.next(); ++i) {
320 double r_ln = rs.getDouble(
"m_ln");
321 assertEquals(
Double.compare(r_ln, 2.302585092994046), 0);
324 d_ln =
"select {fn ln(10)} as m_ln";
325 rs = statement.executeQuery(d_ln);
326 for (
int i = 0; rs.next(); ++i) {
327 double r_ln = rs.getDouble(
"m_ln");
328 assertEquals(
Double.compare(r_ln, 2.302585092994046), 0);
332 String d_log10 =
"select {fn log10(10)} as m_log10";
333 rs = statement.executeQuery(d_log10);
334 for (
int i = 0; rs.next(); ++i) {
335 double r_log10 = rs.getDouble(
"m_log10");
336 assertEquals(
Double.compare(r_log10, 1), 0);
340 String d_abs =
"select {fn abs(-1.45)} as m_abs";
341 rs = statement.executeQuery(d_abs);
342 for (
int i = 0; rs.next(); ++i) {
343 float r_abs = rs.getFloat(
"m_abs");
344 assertEquals(
Float.compare(r_abs, (
float) Math.abs(-1.45)), 0);
348 String d_power =
"select {fn power(2,10)} as YYY";
349 rs = statement.executeQuery(d_power);
350 for (
int i = 0; rs.next(); ++i) {
351 float yyy = rs.getFloat(
"YYY");
352 assertEquals(
Float.compare((
float) Math.pow(2, 10), yyy), 0);
355 String d_truncate =
"select {fn truncate(2.01,1)} as YYY";
356 rs = statement.executeQuery(d_truncate);
357 for (
int i = 0; rs.next(); ++i) {
358 float yyy = rs.getFloat(
"YYY");
359 assertEquals(
Float.compare(2.0F, yyy), 0);
363 String d_length =
"select {fn length('12345')} as YYY";
364 rs = statement.executeQuery(d_length);
365 for (
int i = 0; rs.next(); ++i) {
366 int yyy = rs.getInt(
"YYY");
367 assertEquals(5, yyy);
371 String d_quarter =
"select {fn quarter({d '2005-01-24'})} as m_quarter";
372 rs = statement.executeQuery(d_quarter);
373 for (
int i = 0; rs.next(); ++i) {
374 int r_quarter = rs.getInt(
"m_quarter");
375 assertEquals(1, r_quarter);
379 String d_dayofyear =
"select {fn DAYOFYEAR({d '2005-01-24'})} as m_dayofyear";
380 rs = statement.executeQuery(d_dayofyear);
381 for (
int i = 0; rs.next(); ++i) {
382 int r_dayofyear = rs.getInt(
"m_dayofyear");
383 assertEquals(24, r_dayofyear);
387 String d_dayofweek =
"select {fn dayofweek({d '2005-01-24'})} as m_dayofweek";
388 rs = statement.executeQuery(d_dayofweek);
389 for (
int i = 0; rs.next(); ++i) {
390 int r_dayofweek = rs.getInt(
"m_dayofweek");
391 assertEquals(2, r_dayofweek);
394 String d_dayofmonth =
"select {fn dayofmonth({d '2005-01-24'})} as m_dayofmonth";
395 rs = statement.executeQuery(d_dayofmonth);
396 for (
int i = 0; rs.next(); ++i) {
397 int r_dayofmonth = rs.getInt(
"m_dayofmonth");
398 assertEquals(24, r_dayofmonth);
401 String d_hour =
"select {fn hour({ts '2005-01-24 10:11:12'})} as m_hour";
402 rs = statement.executeQuery(d_hour);
403 for (
int i = 0; rs.next(); ++i) {
404 int r_hour = rs.getInt(
"m_hour");
405 assertEquals(10, r_hour);
410 "select {fn TIMESTAMPADD(SQL_TSI_DAY, 1, CURRENT_DATE())} m, TIMESTAMPADD(SQL_TSI_WEEK, 1, CURRENT_DATE) y";
411 ResultSet rx = statement.executeQuery(d_c);
412 for (
int i = 0; rx.next(); ++i) {
413 Date r_m = rx.getDate(
"m");
414 Date r_y = rx.getDate(
"y");
418 d_c =
"select TIMESTAMPADD(SQL_TSI_DAY, 1, CURRENT_DATE) as m_zzz";
419 rs = statement.executeQuery(d_c);
420 for (
int i = 0; rs.next(); ++i) {
421 Timestamp r_zzz = rs.getTimestamp(
"m_zzz");
424 d_c =
"select TIMESTAMPADD(SQL_TSI_DAY, 1, CURRENT_DATE_TIME) as m_zzz";
426 rs = statement.executeQuery(d_c);
428 }
catch (SQLException sE) {
429 assertTrue(sE.toString().contains(
"CURRENT_DATE_TIME' not found in any table"));
430 }
catch (Exception ex) {