AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Oracle placeholder variables in jdbc

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases
View previous topic :: View next topic  
Author Message
user@domain.invalid
Guest





PostPosted: Thu Nov 20, 2003 12:34 pm    Post subject: Oracle placeholder variables in jdbc Reply with 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.

Thanks for any help

Kevin.

Back to top
Tore Skogly
Guest





PostPosted: Thu Nov 20, 2003 4:55 pm    Post subject: Re: Oracle placeholder variables in jdbc Reply with quote



[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
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.