java.sql.SQLException: ORA-01006
Hi everybody,
I've an issue, and can't find an answer. (I've been searching on google, reading these forums, reading examples, ....) but didn't find my answer.
Here is my problem:
I have an application who needs to update, insert or delete records in an Oracle DB. For the update and delete no issue but for the insert...
here is my code:
publiclong addJob(String rank, String beginValidity, String endValidity){
PreparedStatement psp =null;
long beginV, endV;
SimpleDateFormat sdfParser =new SimpleDateFormat(ContentTypeConstant.DATE_FORMAT);
String sql = DefaultDAO.getSQL(SQL_INSERT);
Connection conn =null;
long returnedId = 0;
try{
conn = getConnection();
psp = conn.prepareStatement(sql);
if (rank ==null){
psp.setNull(1, java.sql.Types.NUMERIC);
}else{
psp.setString(1, rank);
}
if (beginValidity ==null){
psp.setNull(2, java.sql.Types.DATE);
}else{
beginV = sdfParser.parse(beginValidity).getTime();
psp.setDate(2,new java.sql.Date(beginV));
}
if (endValidity ==null){
psp.setNull(3, java.sql.Types.DATE);
}else{
endV = sdfParser.parse(endValidity).getTime();
psp.setDate(3,new java.sql.Date(endV));
}
psp.execute();
sql = DefaultDAO.getSQL(SQL_CURRVAL);
ResultSet rSet = psp.executeQuery(sql);
if (rSet.next()){
logger.debug("Je suis dans le Resultat de JOB=>CURRVAL ");
returnedId = rSet.getLong(1);
}
conn.commit();
psp.close();
rSet.close();
conn.close();
}catch (SQLException e){
logger.error("Last SQL executed " + sql);
logger.warn(e);
}catch (ClassNotFoundException e){
logger.error("Exception " + e);
}catch (ParseException e){
logger.error("Exception " + e);
}
return returnedId;
}
the connection and the incoming parameters are checked.
i have a table named JOB and a trigger that uses the JOB_SEQ.nextval to fill in the id.
But when it execute this code i get:
Last SQL executed insert into job (rank, begin_validity, end_validity) values (?, ?, ?)
be.bvdit.bvdWeb.DAO.JobDAO - java.sql.SQLException: ORA-01006: la variable attache (bind variable) n'existe pas
(it's in french meaning= bind variable does not exists)
or sometimes it says the same message but telling this for
select JOB_SEQ.currval from dual
i forgot to tell:
- SQL_INSERT = insert into job (rank, begin_validity, end_validity) values (?, ?, ?)
- SQL_CURRVAL =select JOB_SEQ.currval from dual
All help will be welcome.
Thanks in advance.
Message was edited by:
Wcfly
Message was edited by:
Wcfly

