JDBC: complains about invalid sign but seems fine

前端 未结 3 1428
[愿得一人]
[愿得一人] 2021-01-25 18:41

I have to use JDBC to write to a database (hibernate/ibatis is not an option) and my database is Oracle 11g.

I create the following query: insert into user(user_id

3条回答
  •  礼貌的吻别
    2021-01-25 19:26

    As I put in a comment above, the issue could be due to the extra Semicolon at the end of your SQL statement. see this article

    You may also want to look at PreparedStatments to make your life easier. Here would be a rough translation of your above code. I have left some parts, and there are most likely errors.

    String query = "insert into user(user_id, username, age, creation_ts) values(?,?,?,?)";
    PreparedStatement pstmt = conn.prepareStatement(query);
    ... //fill in all your parameters
    pstmt.setTimestamp(4, new Timestamp(System.currentTimeMillis()) );
    ... //execute here
    

提交回复
热议问题