Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8988325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:59:41+00:00 2026-06-15T21:59:41+00:00

I am using jooq to build queries for Oracle. Everything works fine except for

  • 0

I am using jooq to build queries for Oracle. Everything works fine except for dates:

public static void main(String[] args) throws SQLException {
    java.sql.Timestamp now = new java.sql.Timestamp(new Date().getTime());
    Connection con = DriverManager.getConnection(... , ... , ...);
    final Factory create = new OracleFactory(con);
    Statement s = con.createStatement();
    s.execute("create table test_table ( test_column DATE )");
    s.execute("insert into test_table values (to_date('20111111', 'yyyymmdd'))");

    // -- using to_date
    ResultSet rs = s.executeQuery("select count(1) from test_table where test_column<to_date('20121212', 'yyyymmdd')");
    rs.next();
    System.out.println(""+rs.getInt(1));
    rs.close();     

    // -- using a preparedstatement with java.sql.timestamp
    PreparedStatement ps = con.prepareStatement("select count(1) from test_table where test_column<?");
    ps.setTimestamp(1,now);
    rs = ps.executeQuery();
    rs.next();
    System.out.println(""+rs.getInt(1));
    rs.close();

    // -- using jooq with java.sql.timestamp
    final org.jooq.Table<org.jooq.Record> table = create.tableByName("TEST_TABLE");
    final org.jooq.SelectSelectStep sss = create.select(create.count());
    final org.jooq.SelectJoinStep sjs = sss.from(table);
    final org.jooq.SelectConditionStep scs = sjs.where(create.fieldByName("TEST_COLUMN").lessThan(now));
    System.out.println(scs.toString());
    rs = s.executeQuery(scs.toString());
    rs.next();
    System.out.println(""+rs.getInt(1));
    rs.close();

    s.close();

}

Gives the following output:

   1
   1
   select count(*) from "TEST_TABLE" where "TEST_COLUMN" < '2012-12-12 19:42:34.957'
   Exception in thread "main" java.sql.SQLDataException: ORA-01861: literal does not match format string

I would have thought that JOOQ would check the type of Object in lessThan(Object)
to determine whether it can come up with a reasonable conversion, but apparently it
just does an Object.toString() in this case. I also remember that I never had issues with date queries via JOOQ in MySQL (although this is a while back). What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:59:42+00:00Added an answer on June 15, 2026 at 9:59 pm

    I suspect that this issue is due to the fact that create.fieldByName() doesn’t know the type of the column (hence, Object), and coerces that unknown type on the right hand side of the comparison predicate. That should be fixed in jOOQ. I have registered #2007 for this:
    https://github.com/jOOQ/jOOQ/issues/2007

    In the mean time, try explicitly setting the type on your field:

    create.fieldByName(Timestamp.class, "TEST_COLUMN").lessThan(now)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the C# Facebook SDK 5.0.3 everything works fine whit the client.Get(/me). But when
I'm using Maven to build and deploy jOOQ . I now want to start
I'm trying to use jOOQ to build SQL queries in some generic code. I'm
Using import datetime in python, is it possible to take a formatted time/date string
using Telerik.WinControls.Data; using Telerik.WinControls.UI.Export; namespace Directory { public partial class radForm : Form {
Using PL/SQL, how can I remove sentences, except the first occurrence of a sentence
I'm using Jooq as the SQL layer in my application. It generates the code/pojos/records/routines
using System; f.involk() failed since it needs a string parameter, how to correct the
Using server-side C#, how can I convert a querystring to a JSON string of
I'm using jOOQ to get id which in MySQL is smallint unsigned primary key

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.