 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
user@domain.invalid Guest
|
Posted: Thu Nov 20, 2003 12:34 pm Post subject: Oracle placeholder variables in jdbc |
|
|
Hello Can anybody help me with this ;-)
say I have an sql statement with place holder variables in it
in oracle
String sql = "select * from student where id = :1 and name = :2";
how do I pass the place holder values to a jdbc statement with out
acctually having to edit the string.
do I have to use the jdbc OCI driver and what is the syntax
I can do it in toad and python i was wondering what the java equivalent was.
Thanks for any help
Kevin.
|
|
| Back to top |
|
 |
Tore Skogly Guest
|
Posted: Thu Nov 20, 2003 4:55 pm Post subject: Re: Oracle placeholder variables in jdbc |
|
|
[email]user (AT) domain (DOT) inva[/email]lid wrote:
| Quote: | Hello Can anybody help me with this ;-)
say I have an sql statement with place holder variables in it
in oracle
String sql = "select * from student where id = :1 and name = :2";
how do I pass the place holder values to a jdbc statement with out
acctually having to edit the string.
do I have to use the jdbc OCI driver and what is the syntax
I can do it in toad and python i was wondering what the java equivalent
was.
|
Read about PreparedStatement in the Java API.
String sql="select * from student where id = ? and name = ?
PreparedStatement statement = connection.prepareStatement(sql);
statement.setString(1,"id_variable");
statement.setString(2,"name_variable");
--
ToreS
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|