• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

DATEADD in JDBC template

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying a query select with jdbc and spring boot,

I want select informations where my creation date value is LESS than now minus 30.

I tried like this :



I have an error like this :




Anyone has idea ? Thanks
 
Marshal
Posts: 77212
370
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't know. What happens when you run that query from the command line/terminal?
Moving to our databases and Spring fora.
 
Gerard Geded
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Don't know. What happens when you run that query from the command line/terminal?
Moving to our databases and Spring fora.



In SQL Console that's work, but in my java code no...
 
Marshal
Posts: 4084
554
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Gerard Geded wrote:I tried like this :


Can you show the actual code where this is used?
 
Gerard Geded
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ron McLeod wrote:

Gerard Geded wrote:I tried like this :


Can you show the actual code where this is used?



This code works with console SQL :

 
Ron McLeod
Marshal
Posts: 4084
554
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The concatenated string will be:with no space between information and WHERE
 
Gerard Geded
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ron McLeod wrote:The concatenated string will be:with no space between information and WHERE




No looks my screenshot, this part it's OK, the problem is with the DATE but i don't know what exactly
sql.PNG
[Thumbnail for sql.PNG]
 
Ron McLeod
Marshal
Posts: 4084
554
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This:
and this:


are obviously not the same.  One has a table name of information, the other has UsersAccount.
 
Gerard Geded
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ron McLeod wrote:This:
and this:


are obviously not the same.  One has a table name of information, the other has UsersAccount.



Considered the last screenshot it's good, sorry for the confuse
 
Bartender
Posts: 2266
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I notice this lastTreatment =< Now() - INTERVAL 30 MINUTE.
Should it be lastTreatment < NOW() - INTERVAL 30 MINUTE ?
 
Campbell Ritchie
Marshal
Posts: 77212
370
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, now you come to mention it, should there be a space between the = and < characters? That doesn't look right.
 
Ron McLeod
Marshal
Posts: 4084
554
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is =< a valid comparison operator?  Shouldn't it be <= ?
reply
    Bookmark Topic Watch Topic
  • New Topic