| Author |
SQL built-in functions in PreparedStatement?
|
Antonio Giovanni
Ranch Hand
Joined: Jun 27, 2005
Posts: 85
|
|
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 ]
|
 |
Makarand Parab
Ranch Hand
Joined: Dec 10, 2004
Posts: 121
|
|
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
Joined: Jun 27, 2005
Posts: 85
|
|
I am actually using DB2 UDB.. some casting issue.. !!..
|
 |
Makarand Parab
Ranch Hand
Joined: Dec 10, 2004
Posts: 121
|
|
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
Joined: Jun 27, 2005
Posts: 85
|
|
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
Joined: Jun 27, 2005
Posts: 85
|
|
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..
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26155
|
|
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.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Antonio Giovanni
Ranch Hand
Joined: Jun 27, 2005
Posts: 85
|
|
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
|
 |
 |
|
|
subject: SQL built-in functions in PreparedStatement?
|
|
|