| Author |
How to use Oracle sequence in preparedstatement
|
Sidhu roy
Greenhorn
Joined: Aug 11, 2011
Posts: 15
|
|
String str="insert into table1 values(?,?)";
ps=con.prepareStatement(str);
ps.setInt(1,id);
now i want to insert sequence value int the second column of the table by using sequence.nextval , i did it using Statement but i want to do it with preparedstatement please help me
|
 |
Martin Vajsar
Bartender
Joined: Aug 22, 2010
Posts: 2331
|
|
|
You'll do it the same with PreparedStatement as you did with a Statement. There is no difference. The sequence is a database object, not a variable, therefore you don't use a parameter (bind variable) to specify it.
|
 |
James Boswell
Ranch Hand
Joined: Nov 09, 2011
Posts: 657
|
|
replacing SEQUENCE_NAME with the name of your sequence.
|
 |
Wendy Gibbons
Bartender
Joined: Oct 21, 2008
Posts: 1098
|
|
|
hi Sidhu, please read this little item sqlColumnLists
|
 |
Sidhu roy
Greenhorn
Joined: Aug 11, 2011
Posts: 15
|
|
|
thanks James Boswell and everyone, its working.
|
 |
 |
|
|
subject: How to use Oracle sequence in preparedstatement
|
|
|