This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JDBC and the fly likes java code inside sql functions? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java code inside sql functions?" Watch "java code inside sql functions?" New topic
Author

java code inside sql functions?

rish obe
Greenhorn

Joined: Jun 19, 2007
Posts: 6
I am running a sql query which uses some sql functions like date_add() or max()

Query is something like : delete from <tablename> where date=date_add(<date>,interval <expression> unit)

I wish to write the above query in java code
The problem is i am not able to pass the parameters to the sql functions in java code.

"delete from student where date=date_add("+date_variable+","+parameter_@+")"

How can this be done.
Any inputs?

Many thanks!
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

Can you post your java code? It's hard to know what you're doing wrong without see the JDBC code.


My Blog: Down Home Country Coding with Scott Selikoff
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1131

Rish,
The usual way to achieve your aim is to use a PreparedStatement.

Good Luck,
Avi.
 
Don't get me started about those stupid light bulbs.
 
subject: java code inside sql functions?