SimpleJdbcCall工作调用n次存储过程,然后抛出错误。

时间:2022-10-02 23:40:36

I've the next error:

我下一个错误:

[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 [com.sun.gjc.spi.jdbc40.DataSource40@12ea240]
[http-thread-pool-8080(5)] DEBUG o.s.j.support.SQLErrorCodesFactory - Database product name cached for DataSource [com.sun.gjc.spi.jdbc40.DataSource40@12ea240]: 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

But, it's strange, because, the same SP works without errors, but when is called N-times throws the error. I'm using Spring with a pooled connection through Glassfish 3.1.2. to a Sqlserver 2005 database.

但是,这很奇怪,因为相同的SP在没有错误的情况下工作,但是当被调用n次时就会抛出错误。我使用的是Spring,它是通过Glassfish 3.1.2来连接的。到一个Sqlserver 2005数据库。

Here is the java function

这是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;
        }
    }

1 个解决方案

#1


0  

It looks like that you are sharing your "insert" - bean among threads. Try using scope="prototype" on your insert bean, so you make sure that you are getting a new instance for each call.

看起来您在线程*享您的“插入”bean。尝试在您的插入bean上使用scope="prototype",这样您就可以确保每个调用都获得一个新的实例。

#1


0  

It looks like that you are sharing your "insert" - bean among threads. Try using scope="prototype" on your insert bean, so you make sure that you are getting a new instance for each call.

看起来您在线程*享您的“插入”bean。尝试在您的插入bean上使用scope="prototype",这样您就可以确保每个调用都获得一个新的实例。