public void runSp(List<String> params, DataSource dataSource, String spName) throws SQLException { StringBuffer sb = new StringBuffer("{call " + spName + " ("); for (int i = 0; i < params.size() - 1; i++) { sb.append("?,"); } sb.append("?)}"); String callString = sb.toString(); LOGGER.info("[runSp] Running statement: " + callString); Connection conn = getConnection(dataSource); conn.setAutoCommit(false); CallableStatement cs = conn.prepareCall(callString); for (int i = 0; i < params.size(); i++) { cs.setString(i + 1, params.get(i)); } try { cs.execute(); conn.commit(); LOGGER.info("sp completed successfully"); } catch (Exception e) { LOGGER.info("sp failed", e); conn.rollback(); } finally { cs.close(); conn.close(); } }
This exception is thrown when the method is called while the program is running. The program needs to call SQL Server’s stored procedure during the run, but there is already a commit of the item in the store.
I also added Java code to Java code to throw out this one. After I tried to remove control from the Java code, there were no errors. The specific reasons are still in the learning process, I hope you can give me some advice.
Read More:
- Grpc client access server prompt: RPC error: code = unimplemented desc = unknown service possible reasons
- Error: current transaction is aborted, commands ignored until end of transaction blockp
- com.microsoft.sqlserver . jdbc.SQLServerException : invalid object name ‘XX’
- [Java] spring transaction control configuration error, application- persstence.xml Transaction manager report red in file
- Spring configuration transaction, JUnit unit test error “failed to load ApplicationContext”
- Spring failed to commit the transaction
- Solve “error: failed to commit transaction” in arch Linux
- On error goto (resume)
- Experience of using on error resume next in VBScript
- Ror deployed to heroku has application error and code = H10 desc = “app crashed” problems
- Server Tomcat v8.0 Server at localhost failed to start.
- Server Tomcat v7.0 server at localhost failed to start
- C ා imitate on error resume next in VB
- CentOS Liunx 7 uses rdesktop to remotely connect to the Alibaba Cloud server and it appears Failed to connect, CredSSP required by server.
- [Solved] Tomcat Failed to Start Error: Server Tomcat v8.5 Server at localhost failed to start
- Common mistakes in WCF distributed development (15): Communication with the underlying transaction manager has failed.
- Failed: error connecting to db server: server returned error on SASL authentication step: Authentica
- How to Fix adb_server_notify: ADB server connection failed
- Springboot + mybatis plus transaction management
- The transaction log for database ‘xxxx’ is full due to AVAILABILITY_REPLICA error message in SQL Ser…