我们使用自己的数据源,它建立在PoolDataSourceFactory
之上<bean id="dataSource" class="oracle.ucp.jdbc.PoolDataSourceFactory"
factory-method="getPoolDataSource" lazy-init="true" >
<property name="connectionFactoryClassName" value="oracle.jdbc.pool.OracleDataSource"/>
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="URL" value="${jdbc.url}" />
<property name="connectionWaitTimeout" value="30" />
<property name="minPoolSize" value="3"/>
<property name="maxPoolSize" value="20"/>
<property name="abandonedConnectionTimeout" value="300"/>
<property name="inactiveConnectionTimeout" value="900"/>
<property name="validateConnectionOnBorrow" value="true"/>
<property name="exceptionManager" value="exceptionManager"/>
</bean>
Tomcat服务器日志:
2017-10-17 20:33:25,913错误[http-nio-8101-exec-4] u: - JdbcStoredProcedureWrapper.selectUserDetails:无法执行存储过程:Exception [{}] org.springframework.jdbc.UncategorizedSQLException :CallableStatementCallback;未分类SQL的SQLException [{? =致电SP_NAME(?,?,?,)}]; SQL状态[null];错误代码[31];连接已关闭:连接已关闭;嵌套异常是java.sql.SQLException:连接已关闭:在org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate的org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:84)处关闭连接。 (AbstractFallbackSQLExceptionTranslator.java:81)org.springframework上的org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:1137)。 jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1173)atg.springframework.jdbc.object.StoredProcedure.execute(StoredProcedure.java:142)at com.vodafone.gdsp.provisioning.dataaccess.jdbc.JdbcStoredProcedureCaller.execute( JdbcStoredProcedureCaller.java:561)at com.vodafone.gdsp.provisioning.dataaccess.jdbc.JdbcStore
如果有任何帮助,我会坚持这个问题
请帮我解决上述问题
答案 0 :(得分:0)
经过一周的努力,我终于解决了问题:
解决方案:很可能是基于全局临时表(GTT)打开游标,该表是使用ON COMMIT DELETE ROWS选项创建的。并且ORA-08103:对象不再存在的原因错误是紧跟在delete语句之后的commit语句。 DBA团队不同意将GTT更改为提交保留行,所以最后我在Java服务层[实现Spring - 程序化事务]中添加了代码库但忘记添加transactionManager.rollback(status)int catch块这导致了连接关闭错误。
FiX:
package com.test;
import java.util.List;
import javax.sql.DataSource;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
public class StudentJDBCTemplate implements StudentDAO {
private DataSource dataSource;
private JdbcTemplate jdbcTemplateObject;
private PlatformTransactionManager transactionManager;
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
this.jdbcTemplateObject = new JdbcTemplate(dataSource);
}
public void setTransactionManager(PlatformTransactionManager transactionManager) {
this.transactionManager = transactionManager;
}
public void create(String name, Integer age, Integer marks, Integer year){
TransactionDefinition def = new DefaultTransactionDefinition();
TransactionStatus status = transactionManager.getTransaction(def);
try {
String SQL1 = "insert into Student (name, age) values (?, ?)";
jdbcTemplateObject.update( SQL1, name, age);
// Get the latest student id to be used in Marks table
String SQL2 = "select max(id) from Student";
int sid = jdbcTemplateObject.queryForInt( SQL2 );
String SQL3 = "insert into Marks(sid, marks, year) " + "values (?, ?, ?)";
jdbcTemplateObject.update( SQL3, sid, marks, year);
System.out.println("Created Name = " + name + ", Age = " + age);
transactionManager.commit(status);
}
catch (DataAccessException e) {
System.out.println("Error in creating record, rolling back");
**transactionManager.rollback(status);**
throw e;
}
return;
}
public List<StudentMarks> listStudents() {
String SQL = "select * from Student, Marks where Student.id=Marks.sid";
List <StudentMarks> studentMarks = jdbcTemplateObject.query(SQL,
new StudentMarksMapper());
return studentMarks;
}
}