This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pass TO_DATE to preparestatement

 
pavan sharma
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic