Spring加载一些配置文件中不存在的bean,如DB2,SYBASE,Derby,H2等等,Error while extracting database product name

来源:互联网 发布:公告管理系统源码 编辑:程序博客网 时间:2024/06/13 15:17

仔细看一下日志的输出

[] INFO [Timer-0] Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml][] DEBUG [Timer-0] Using JAXP provider [com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl][] DEBUG [Timer-0] Found beans DTD [http://www.springframework.org/dtd/spring-beans-2.0.dtd] in classpath: spring-beans-2.0.dtd[] DEBUG [Timer-0] Loading bean definitions[] DEBUG [Timer-0] Creating shared instance of singleton bean 'DB2'[] DEBUG [Timer-0] Creating instance of bean 'DB2'[] DEBUG [Timer-0] Eagerly caching bean 'DB2' to allow for resolving potential circular references[] DEBUG [Timer-0] Finished creating instance of bean 'DB2'[] DEBUG [Timer-0] Creating shared instance of singleton bean 'Derby'[] DEBUG [Timer-0] Creating instance of bean 'Derby'[] DEBUG [Timer-0] Eagerly caching bean 'Derby' to allow for resolving potential circular references[] DEBUG [Timer-0] Finished creating instance of bean 'Derby'[] DEBUG [Timer-0] Creating shared instance of singleton bean 'H2'[] DEBUG [Timer-0] Creating instance of bean 'H2'[] DEBUG [Timer-0] Eagerly caching bean 'H2' to allow for resolving potential circular references[] DEBUG [Timer-0] Finished creating instance of bean 'H2'[] DEBUG [Timer-0] Creating shared instance of singleton bean 'HSQL'[] DEBUG [Timer-0] Creating instance of bean 'HSQL'[] DEBUG [Timer-0] Eagerly caching bean 'HSQL' to allow for resolving potential circular references[] DEBUG [Timer-0] Finished creating instance of bean 'HSQL'[] DEBUG [Timer-0] Creating shared instance of singleton bean 'Informix'[] DEBUG [Timer-0] Creating instance of bean 'Informix'[] DEBUG [Timer-0] Eagerly caching bean 'Informix' to allow for resolving potential circular references[] DEBUG [Timer-0] Finished creating instance of bean 'Informix'[] DEBUG [Timer-0] Creating shared instance of singleton bean 'MS-SQL'[] DEBUG [Timer-0] Creating instance of bean 'MS-SQL'[] DEBUG [Timer-0] Eagerly caching bean 'MS-SQL' to allow for resolving potential circular references[] DEBUG [Timer-0] Finished creating instance of bean 'MS-SQL'[] DEBUG [Timer-0] Creating shared instance of singleton bean 'MySQL'[] DEBUG [Timer-0] Creating instance of bean 'MySQL'[] DEBUG [Timer-0] Eagerly caching bean 'MySQL' to allow for resolving potential circular references[] DEBUG [Timer-0] Finished creating instance of bean 'MySQL'[] DEBUG [Timer-0] Creating shared instance of singleton bean 'Oracle'[] DEBUG [Timer-0] Creating instance of bean 'Oracle'[] DEBUG [Timer-0] Eagerly caching bean 'Oracle' to allow for resolving potential circular references[] DEBUG [Timer-0] Finished creating instance of bean 'Oracle'[] DEBUG [Timer-0] Creating shared instance of singleton bean 'PostgreSQL'[] DEBUG [Timer-0] Creating instance of bean 'PostgreSQL'[] DEBUG [Timer-0] Eagerly caching bean 'PostgreSQL' to allow for resolving potential circular references[] DEBUG [Timer-0] Finished creating instance of bean 'PostgreSQL'[] DEBUG [Timer-0] Creating shared instance of singleton bean 'Sybase'[] DEBUG [Timer-0] Creating instance of bean 'Sybase'[] DEBUG [Timer-0] Eagerly caching bean 'Sybase' to allow for resolving potential circular references[] DEBUG [Timer-0] Finished creating instance of bean 'Sybase'[] INFO [Timer-0] SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase][] DEBUG [Timer-0] Looking up default SQLErrorCodes for DataSource [org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy@431f5ba2][] DEBUG [Timer-0] Fetching JDBC Connection from DataSource[] DEBUG [Timer-0] Fetching JDBC Connection from DataSource[] DEBUG [Timer-0] Returning JDBC Connection to DataSource[] WARN [Timer-0] Error while extracting database product name - falling back to empty error codesorg.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: The Network Adapter could not establish the connectionat org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:296)at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:320)at org.springframework.jdbc.support.SQLErrorCodesFactory.getErrorCodes(SQLErrorCodesFactory.java:216)at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.setDataSource(SQLErrorCodeSQLExceptionTranslator.java:140)at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.<init>(SQLErrorCodeSQLExceptionTranslator.java:103)at org.springframework.jdbc.support.JdbcAccessor.getExceptionTranslator(JdbcAccessor.java:99)at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:212)at org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithListResult(SqlMapClientTemplate.java:249)at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:296)at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:290)at cn.cisco.com.dao.impl.MonDAOImpl.prpt_map_siteid(MonDAOImpl.java:111)at cn.cisco.com.service.impl.MonServiceImpl.monitorPrptSiteId(MonServiceImpl.java:47)at cn.cisco.com.main.Monitor$4.run(Monitor.java:94)at java.util.TimerThread.mainLoop(Unknown Source)at java.util.TimerThread.run(Unknown Source)Caused by: java.sql.SQLException: The Network Adapter could not establish the connection
如黑体部分所示,它去加载了sql-error-codes.xml文件了,而那些不存在的bean都在这个文件里定义了

然后我继续往后看日志

SqlMapClient operation; SQL [];   --- The error occurred in cn/cisco/com/bean/monitor.xml.  --- The error occurred while applying a parameter map.  --- Check the prpt_map_siteid-InlineParameterMap.  --- Check the statement (query failed).  --- Cause: java.sql.SQLRecoverableException: Io exception: Connection reset by peer: socket write error; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:   --- The error occurred in cn/cisco/com/bean/monitor.xml.  --- The error occurred while applying a parameter map.  --- Check the prpt_map_siteid-InlineParameterMap.  --- Check the statement (query failed).  
说是我的sql query语句出错了,参数映射不对

SELECT   siteid            FROM   某表            GROUP BY    siteid            HAVING   COUNT (DISTINCT hgssiteid) >= 2
然后我把这个语句直接粘贴到toad里可以正常运行的

所以说这里没有问题


而且日志中的这个sql query错,是只有第二次运行的时候才会出错

我运行主函数的时候,这个方法就已经运行过一次了,没有任何问题,然后第二次是24小时候运行,当我第二天早上来看的的时候,就发现日志的问题,可是我很费解,这个语句根本没有错误啊???