Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

chapter 10 OCPJP Study guide Sybex: incorrect format for TIMESTAMP

 
Bartender
Posts: 4633
182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,

I'm working on chapter 10 from the Sybex OCPJP study guide, and I ran the code given on page 509:

However, I keep getting this error:

java.sql.SQLDataException: The syntax of the string representation of a date/time value is incorrect.
at org.apache.derby.client.am.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
at org.apache.derby.client.am.ClientStatement.executeUpdate(Unknown Source)
at chapter10.justcodes.SetupDerbyDatabase.main(SetupDerbyDatabase.java:37)
Caused by: ERROR 22007: The syntax of the string representation of a date/time value is incorrect.

Now, I have no idea what is wrong in my code. Someone who sees what I'm doing wrong?
 
Enthuware Software Support
Posts: 4577
45
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The format is hh:mm:ss[.nnnnnn] so try changing 2001-05-06 02:15 to 2001-05-06 00:02:15
 
Piet Souris
Bartender
Posts: 4633
182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul, that worked!

But I am still baffled:

1) my code is from the book of Jeanne and Scott and so far I have not seen any remarks from people for which this also does not work (am I really the first?)
2) if you look at the official Java DB documentation from Apache, it says:

Derby supports the following formats for TIMESTAMP:
yyyy-mm-dd hh[:mm[:ss[.nnnnnn]]]
yyyy-mm-dd-hh[.mm[.ss[.nnnnnn]]]



and I simply used the hh:mm format.

Hmmm... remarkable. But thanks again!
 
Paul Anilprem
Enthuware Software Support
Posts: 4577
45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using the same version of derby?
 
Piet Souris
Bartender
Posts: 4633
182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I had some problems with NetBeans among other things, and a couple of days ago I downloaded both Java 1.8.0-131 and NetBeans 8.2 and installed these.
The version of the Derby database, according to the Release Notes, is 10.11.1.1. But you are right. The quote I gave seems to be from version 10.1.

I just looked at the documentation of 10.11, and it says about Timestamp:

TIMESTAMP

Dates, times, and timestamps cannot be mixed with one another in expressions.

Derby supports the following formats for TIMESTAMP:
yyyy-mm-dd hh:mm:ss[.nnnnnnnnn]
yyyy-mm-dd-hh.mm.ss[.nnnnnnnnn]
The first of the two formats above is the java.sql.Timestamp format.


So problem solved!

Again: thank you very much!

@Jeanne:
should this not be reported somewhere?
 
author & internet detective
Posts: 40747
827
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it is on the Derby setup blog post page
 
I hired a bunch of ninjas. The fridge is empty, but I can't find them to tell them the mission.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic