• 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
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SQL built-in functions in PreparedStatement?

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This kind of a PreparedStatement is throwing an exception..



I have never tried anything like this before,.. but curious to know if this is ok..or not..?? I appreciate your help..
At the same time, i'll also see what the cause of the exception is..

Thanks again
[ August 04, 2005: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What exception is it throwing? Can you please submit that so that we can know the exact problem.

Personally i feel the PreparedStatement is creating the problem
INSERT INTO LIBRARYNAME.TABNAME VALUES (?,?,?,?,TIME(?),TIME(?),?,?,?,NOW(),?)

Regards
Makarand Parab
 
Antonio Giovanni
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



I am actually using DB2 UDB.. some casting issue.. !!..

 
Makarand Parab
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
That exception is because
INSERT INTO LIBRARYNAME.TABNAME VALUES (?,?,?,?,TIME(?),TIME(?),?,?,?,NOW(),?)
is not allowed
it should be
INSERT INTO LIBRARYNAME.TABNAME VALUES (?,?,?,?,?,?,?,?,?,?,?)
and then pass the value.

Regards
Makarand Parab
 
Antonio Giovanni
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ohh ok.. I am just curious to see if i can do that..
and if it is possible to include SQL built-in functions in
the prepared stmt

Anyway thanks
 
Antonio Giovanni
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to mention:

INSERT INTO LIBRARYNAME.TABNAME VALUES (?,?,?,?,?,?,?,?,?,NOW(),?)

The above Works fine... No problem.. The Time fields i am sending
java.sql.Time values..

 
author & internet detective
Posts: 41860
908
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
Antonio,
When you call TIME(?), are you still passing it a java.sql.Time object? If so, this would explain the casting error. TIME() coverts a var char to a time and therefore expects a String.
 
Antonio Giovanni
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jeanne,

well when i am calling TIME(?), i am actually passing a String value.

Anyway atleast it confirmed to me that i can indeed call SQL built-in functions in PreparedStatement, that was my main question, since it allowed me calling a NOW() function.

Probably the TIME() was giving error because of some casting issue.. maybe it should be like CAST(? AS TIME). I will try this sometime today or in the week-end

Thanks
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic