0

I am trying to insert into a new Database named XpressMP. And I need to insert a timestamp value in that database. Also it doesn't supports TO_TIMESTAMP instead of that, it supports CURRENT_TIMESTAMP which takes no parameter and it gives the current timestamp value.

So in the below SQL, second column and third column data types are Timestamp and total number of columns are 30. So I was thinking to use preparedStatement here to insert the record. And in the below SQL, I have placed CURRENT_TIMESTAMP in second column and third column to get the current timestamp and in the prepared statement I am leaving column for 2 and 3. But after running it gives me exception as

java.sql.SQLException: Driver Error: index parameter to bindParam() must be between 1 and numParameters.

Below is the code, I am using.

private static String insertSQL = "INSERT INTO USER"
            + "("
            + "ID, CREATION_DATE, LAST_MODIFIED_DATE) VALUES"
            + "(?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)";


            preparedStatement.setString(1, "1000015236");

            preparedStatement.setString(4, "Hello");

Can anyone help me what wrong I am doing here?

4

1 回答 1

1

setParameter 的第 n 个索引映射到第 n 个问号,您的索引应该从 1 到 28 开始,并且应该是连续的。

于 2013-02-04T21:24:57.517 回答