Bhushan
Bhushan

Reputation: 6181

SQLException: Unsupported feature

I am trying to get Generated key from sequnce.(Using Servlets & Oracle10)

Following is my code:

query ="insert into TABLE_NAME(COL1,COL2,COL3) values(sysdate,?,SEQ_NAME.nextval)";
PreparedStatement pstmt = con.prepareStatement(query,new String[]{"COL3"});  //Getting error on this line
pstmt.setString(1,Str2);
pstmt.executeUpdate();

ResultSet keyset = pstmt.getGeneratedKeys();
if(keyset.next())
{
    genKey = keyset.getString(1);
}

But I am getting the Exception:

java.sql.SQLException: Unsupported feature

Few days ago this code was working fine. So what might be the reason that this code is not working now? (I haven't changed the JDBC driver war file)

Thanks in advance.

Is there another way of getting the value generated by sequence in the query?

Upvotes: 1

Views: 2318

Answers (1)

sunysen
sunysen

Reputation: 2351

Download the latest JDBC drivers, I think you need at least the 10.2.0.1 drivers and the db also need to be 10.2+

http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc101040.html

or first get the sequence value

String sqlForSeq = "select SEQ_NAME.NEXTVAL from dual";
ResultSet rs = stmt.executeQuery(sqlForSeq);
if (rs.next()) {
    logSeq = rs.getString("NEXTVAL");
}

Upvotes: 1

Related Questions