C
Chowdhury, Ziaul
Hi
Question is how to use SEQUENCE in PrepareStatement
My code is as follows but not working
public void addBook() {
PreparedStatement ps = null;
try {
//initiating Prepare Statement
ps = conn.prepareStatement("INSERT INTO Books (bookno, name, " +
"author, genre, cost) VALUES(bookitm_seq.nextval, ?, ?, ?, ?)");
//bookitm_seq.nextval;
//inserting Data
//ps.setInt(1, 50);
ps.setString(2, BookName);
ps.setString(3, Author);
ps.setInt(4, Genre);
ps.setDouble(5, Cost);
ps.executeUpdate();
If I am using ps.setInt(1, 50) then it is wokring fine. But I need use
Squence which has created with table name bookitm_seq
Question is how to use SEQUENCE in PrepareStatement
My code is as follows but not working
public void addBook() {
PreparedStatement ps = null;
try {
//initiating Prepare Statement
ps = conn.prepareStatement("INSERT INTO Books (bookno, name, " +
"author, genre, cost) VALUES(bookitm_seq.nextval, ?, ?, ?, ?)");
//bookitm_seq.nextval;
//inserting Data
//ps.setInt(1, 50);
ps.setString(2, BookName);
ps.setString(3, Author);
ps.setInt(4, Genre);
ps.setDouble(5, Cost);
ps.executeUpdate();
If I am using ps.setInt(1, 50) then it is wokring fine. But I need use
Squence which has created with table name bookitm_seq