| Author |
pass TO_DATE to preparestatement
|
pavan sharma
Greenhorn
Joined: Dec 19, 2006
Posts: 21
|
|
Hi, PG_DATE is date field in master table in oracle database. I want to set it with preparedstatement like - pstmt.setString(4,TO_DATE(PG_DATE,"DD-MM-YYYY")); it gives error - symbol : method TO_DATE(java.lang.String,java.lang.String) location: class dbbean.addcontentbean pstmt.setString(4,TO_DATE(PG_DATE,"DD-MM-YYYY")); how can i pass it with preparedstatement.
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14669
|
|
Why don't you call pstmt.setDate instead ? If you still want to pass a string, use TO_DATE into your sql statement: INSERT INTO MYTABLE VALUES ( TO_DATE(?, 'DD-MM-YYYY'), .... ) [ January 22, 2007: Message edited by: Satou kurinosuke ]
|
[My Blog]
All roads lead to JavaRanch
|
 |
Muhammad Saifuddin
Ranch Hand
Joined: Dec 06, 2005
Posts: 1318
|
|
Originally posted by pavan sharma: it gives error - symbol : method TO_DATE( java.lang.String, java.lang.String) location: class dbbean.addcontentbean pstmt.setString(4,TO_DATE(PG_DATE,"DD-MM-YYYY"));
its because compiler didn't found any function defined by name TO_DATE in addcontentbean class. its a SQL function so you must define your SQL related things in your SQL Query as Satou defined in a SQL statement.
how can i pass it with preparedstatement.
In preparedStatment SetXXX Method only takes 2 parameter one is value and another its(value) bound location.
|
Saifuddin..
[Linkedin] How To Ask Questions On JavaRanch My OpenSource
|
 |
Muhammad Saifuddin
Ranch Hand
Joined: Dec 06, 2005
Posts: 1318
|
|
Your question is not at all related with JSP. Please select the right forum before posting your query.. Suggestion JDBC forum would be better place to asking JDBC related question.. [ January 22, 2007: Message edited by: Saif uddin ]
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Originally posted by Saif uddin: Suggestion JDBC forum would be better place to asking JDBC related question..
Which is where this thread can now be found.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
 |
|
|
subject: pass TO_DATE to preparestatement
|
|
|