Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

pass TO_DATE to preparestatement

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Let's get him boys! We'll make him read this tiny ad!
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic