This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JDBC and the fly likes can any one help me? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "can any one help me?" Watch "can any one help me?" New topic
Author

can any one help me?

manish kr. pandey
Greenhorn

Joined: Aug 30, 2011
Posts: 14
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

Joined: Jan 30, 2007
Posts: 80

Post the code, without the code it is difficult to find the issue.
Regards
Santhosh
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36464
    
  15
Make sure to post the code on the forum, so we can all see it.
manish kr. pandey
Greenhorn

Joined: Aug 30, 2011
Posts: 14
yes, I know

i have no problem
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3433
    
  47

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

Joined: Aug 30, 2011
Posts: 14
thanks for help me.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can any one help me?
 
Similar Threads
count(*) vs count(id)
Query two tables using hibernate
Get Maximum sal from emp table
JSP and Access
to find the primary key of a table