Java General Error On Insert…???

前端 未结 4 1048
误落风尘
误落风尘 2020-12-22 06:29

I am trying to do an Insert, Update and Delete on a table in MS Access. Everything works fine

for a SELECT statement. But when doing the o

4条回答
  •  执念已碎
    2020-12-22 07:13

    This can happen when you don't commit/close the connection. Ensure that you're committing the connection after executing the statement and are closing the connection (and statement and resultset) in the finally block of the try block where they are been acquired and executed.

    As to why the PreparedStatement is used, it's the common approach to avoid SQL injection attacks and to ease setting fullworthy Java objects like Date, InputStream, etc in a SQL query without the need to convert them to String.

提交回复
热议问题