0

我有下一個錯誤:SimpleJdbcCall時工作調用n次的StoredProcedure然後拋出錯誤

[http-thread-pool-8080(5)] DEBUG o.s.jdbc.core.simple.SimpleJdbcCall - JdbcCall call not compiled before execution - invoking compile 
[http-thread-pool-8080(5)] DEBUG o.s.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource 
[http-thread-pool-8080(5)] DEBUG o.s.jdbc.datasource.DataSourceUtils - Registering transaction synchronization for JDBC Connection 
[http-thread-pool-8080(5)] DEBUG o.s.j.c.m.CallMetaDataProviderFactory - Using org.springframework.jdbc.core.metadata.SqlServerCallMetaDataProvider 
[http-thread-pool-8080(5)] DEBUG o.s.j.c.m.CallMetaDataProvider - Retrieving metadata for BATABASE/dbo/PA_INSERT 
[http-thread-pool-8080(5)] WARN o.s.j.c.m.CallMetaDataProvider - Error while retrieving metadata for procedure columns: com.microsoft.sqlserver.jdbc.SQLServerException: Could not find prepared statement with handle 41. 
[http-thread-pool-8080(5)] DEBUG o.s.jdbc.core.simple.SimpleJdbcCall - Compiled stored procedure. Call string is [{call DATABASE.dbo.PA_INSERT()}] 
[http-thread-pool-8080(5)] DEBUG o.s.jdbc.core.simple.SimpleJdbcCall - SqlCall for procedure [PA_ISolicitudDistincion] compiled 
[http-thread-pool-8080(5)] DEBUG o.s.j.c.m.CallMetaDataContext - Matching [COLUMN1, COLUMN2, COLUMN3] with [] 
[http-thread-pool-8080(5)] DEBUG o.s.j.c.m.CallMetaDataContext - Found match for [] 
[http-thread-pool-8080(5)] DEBUG o.s.jdbc.core.simple.SimpleJdbcCall - The following parameters are used for call {call DATABASE.dbo.PA_INSERT()} with: {} 
[http-thread-pool-8080(5)] DEBUG o.s.jdbc.core.JdbcTemplate - Calling stored procedure [{call DATABASE.dbo.PA_INSERT()}] 
[http-thread-pool-8080(5)] INFO o.s.b.f.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml] 
[http-thread-pool-8080(5)] INFO o.s.j.support.SQLErrorCodesFactory - SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase] 
[http-thread-pool-8080(5)] DEBUG o.s.j.support.SQLErrorCodesFactory - Looking up default SQLErrorCodes for DataSource [[email protected]] 
[http-thread-pool-8080(5)] DEBUG o.s.j.support.SQLErrorCodesFactory - Database product name cached for DataSource [[email protected]]: name is 'Microsoft SQL Server' 
[http-thread-pool-8080(5)] DEBUG o.s.j.support.SQLErrorCodesFactory - SQL error codes for 'Microsoft SQL Server' found 
[http-thread-pool-8080(5)] DEBUG o.s.j.s.SQLErrorCodeSQLExceptionTranslator - Unable to translate SQLException with Error code '201', will now try the fallback translator 
[http-thread-pool-8080(5)] DEBUG o.s.j.s.SQLStateSQLExceptionTranslator - Extracted SQL state class 'S0' from value 'S0004' 
[http-thread-pool-8080(5)] DEBUG o.s.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource 

但是,這是奇怪的,因爲,同一個SP的工作沒有錯誤,但被稱爲N次時拋出錯誤。 我通過Glassfish 3.1.2使用Spring進行池連接。到一個Sqlserver 2005數據庫。

這裏是java功能

public int registrar(Object1 p, 
      Object2 d) 
    { 
     try 
     { 
      final SimpleJdbcCall jdbcCall = (SimpleJdbcCall) context 
        .getBean("insert"); 
      jdbcCall.setCatalogName("DATABASE"); 
      jdbcCall.setSchemaName("dbo"); 
      final MapSqlParameterSource params = new MapSqlParameterSource(); 
      params.addValue("COLUMN1", p.get1()); 
      params.addValue("COLUMN2", p.get1()); 
      params.addValue("COLUMN3", d.get2()); 
      final Map<String, Object> execute = jdbcCall.execute(params); 
      return (Integer) execute.get("IDENTITY"); 
     } 
     catch (DataAccessException e) 
     { 
      return null; 
     } 
    } 
+0

我的第一個猜測是你不小心在多個線程中共享jdbc的東西,而且這個錯誤是一個同步問題。那可能嗎? – mbelow

+0

我有大約10個其他連接池,在調用SP之後,應用程序通過jdbcTemplate執行選擇,並且它是有效的。然後,我必須註冊一個交易,並使用SP。 –

回答

0

它看起來像您共享您的「插入」 - 線程間的豆。嘗試在插入bean上使用scope =「prototype」,以確保每次調用都得到一個新實例。

+0

問題仍然存在,我認爲是連接問題 –

+0

您可以發佈您的彈簧配置的相關部分嗎?我認爲你是在不能共享的線程中共享東西。 – mbelow

相關問題