This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can any one help me?

 
manish kr. pandey
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a table emp

empid empname date_of_joining

i have write a code . and want to select record from table where date_of_joining between to and from .

Query is-
select * from emp where date_of_joining between '"+to+"' and '"from"'


where to and from is java.sql.Date object.

when i execute the code ORA 01847 error occured
 
Santhosh ayiappan
Ranch Hand
Posts: 80
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the code, without the code it is difficult to find the issue.
Regards
Santhosh
 
Campbell Ritchie
Sheriff
Posts: 48424
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure to post the code on the forum, so we can all see it.
 
manish kr. pandey
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, I know

i have no problem
 
Martin Vajsar
Sheriff
Pie
Posts: 3751
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to use bind variables in this statement. If you don't know how to do that, look up a JDBC tutorial to learn the way.

The problem is generally caused by the fact that the database expects the date to be in a format different from what java.sql.Date.toString() produces. Using bind variables is independent of the textual representation of these variables and therefore will solve your problem, making your code immune to SQL injection attacks and more performant as well.
 
manish kr. pandey
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for help me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic