No operations allowed after statement closed

后端 未结 3 1946
逝去的感伤
逝去的感伤 2021-01-03 05:04

I am getting the Exception with the signature No operations allowed after statement closed. inside my Java code where I am trying to insert values into the data

3条回答
  •  抹茶落季
    2021-01-03 05:30

    It may be because of you are using the same prepared statement for two different methods and you close(pst.close()) the statement in one method and still try to use same statement in another method.

    To solve this, get a new connection in a code block you are facing this error and then use statement.

    One thing more if you are using same statement for two different methods and if you do not close statement in any method then you may get this error:

    Parameter index out of range (2 > number of parameters, which is 1).

    because of same statement . So try to get separate connection and statement for block of code and then close the connection and statement.

提交回复
热议问题