Getting SQL errors with prepared statement in JDeveloper 10.1.3.2

I'm using oracle JDBC driver and I connect and update just fine from the SQL Worksheet in JDeveloper.
1) When I have more than 1 placeholder in my SQL statement, the last one is dropped so I get "Invalid column index".
2) When I add an extra one, it prepares OK but gets "ORA-01745: invalid host/bind variable name" on execution if the placeholder is inside the SQL closing paren (this situation is showed below).
3) When an extra one is outside the SQL closing paren, I get "ORA-00933: SQL command not properly ended"
I'm probably missing something obvious but here is the code I'm using:
public void insertToDB(Comment inrecord) throws Exception {
int idx = 0;
try {
this.initialize();
pstmt = conn.prepareStatement(
"INSERT INTO COMMENTS (COMMENT_ID, " +
"LOG_BUS_PROC_CDE, TYPE_CDE, SUBTYPE_CDE, " +
"REF_TYP_CDE, CREATE_USER, CREATE_DATE, " +
"UPDATED_USER, UPDATED_DATE, COMMENT_TEXT) VALUES(" +
"TO_TIMESTAMP('?','YYYY-MM-DD HH24:MI:SS.FF3'), ?, ?, " +
"?, ?, ?, TO_DATE(?,'MM/DD/YYYY'), NULL, NULL, ? ?)");
pstmt.setString(++idx,inrecord.getCommentID());
pstmt.setString(++idx,inrecord.getLogBusProcCDE());
pstmt.setString(++idx,inrecord.getTypeCDE());
pstmt.setString(++idx,inrecord.getSubTypeCDE());
pstmt.setString(++idx,inrecord.getRefTypCDE());
pstmt.setString(++idx,inrecord.getCreateUser());
pstmt.setString(++idx,inrecord.getCreateDate());
pstmt.setString(++idx,inrecord.getCommentTXT());
pstmt.executeUpdate();
conn.commit();
this.terminate();
catch (Exception e) {
conn.rollback();
this.terminate();
throw e;
}

Hi,
actually you increment the index
pstmt.setString(++idx,inrecord.getCommentID());
which means you never have an index of 0 but always start with 1
Frank

Similar Messages

Maybe you are looking for

  • Unable to close down account

    I have been trying to cancel and close down my account - Adobe are not helping the situation. All I get is an email back saying I have to log onto an account web site where my request is listed - on logging on it is not there.  WHY CANT ADOBE JUST DO

  • 'You Are Not Using The Correct Type of Phone Cord' Error

    Having a issue with my fax on my HP Officejet Pro 8500 wireless.  Tried to send a fax, it  received a send error.  I ran fax test and it came back with "You are not using the correct type of phone cord".  Nothing has changed since I last fax'd but I

  • Problem writing to output using servlet

    Hi All, I created a servlet which reads file and writes to output . This works fine when request protocol is http . But if protocol is changed to https servlet doesnt write to output. This servlet is deployed in secure environment as EAR project .But

  • Overheatin​g problem

    hi my hp pavilion g6 working on windows 8 32bits and its heats up alots plse can i hv any tipbits on hw to solve this problem 10x

  • Time series functions are not working in OBIEE for ESSBASE data source

    Hi All, I am facing a problem in OBIEE as I am getting error messages for measure columns with Time series functions(Ago,ToDate and PeriodRolling) in both RPD and Answers. Error is "Target database does not support Ago operation". But I am aware of O