重新启动服务器后,Tomcat服务器的oracle连接每晚都会超时.在重新启动之前,连接没有超时.现在,在早上,应用程序在访问数据库时会抛出JDBC连接错误.重新启动Tomcat可以解决问题.我假设这是由于重新建立连接.我认为,这是由于Oracle数据库超时会话.如何在Oracle 11g中禁用会话超时?
谢谢!
史蒂夫
Config.groovy,dev和test省略.
dataSource {
pooled = true
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
}
// environment specific settings
environments {
production {
dataSource {
driverClassName = "oracle.jdbc.driver.OracleDriver"
username = "XXXXX"
password = "XXXXXX"
dialect = "org.hibernate.dialect.Oracle10gDialect"
dbCreate = "update" // one of 'create', 'create-drop','update'
url = "jdbc:oracle:thin:@XXXXXX:1521:xxxx"
}
} }
Run Code Online (Sandbox Code Playgroud) 如何在jdbc中为oracle数据库检查打开的连接?
注意:conn.isClosed()不能用于此.
关闭连接仍在连接池中 - 为什么?
servlet-
public class Index extends HttpServlet {
TimeZoneService timeZoneService;
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException {
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
timeZoneService = (TimeZoneService) ctx.getBean("timeZoneService");
timeZoneService.loadAllTimeZones();
System.out.println("Done");
}
}
public interface TimeZoneService {
void loadAllTimeZones();
}
public class TimeZoneServiceImpl implements TimeZoneService {
private TimeZoneDao tzDao;
private Map<Long, String> tzOid2JavaName = new HashMap<Long, String>();
public void loadAllTimeZones() {
List<TimeZone> timeZones = tzDao.findAllTimeZones();
for (TimeZone tz : timeZones) {
tzOid2JavaName.put(tz.getOid(), tz.getJavaName());
}
}
public void setTzDao(TimeZoneDao tzDao) { …Run Code Online (Sandbox Code Playgroud) 任何人都可以提供使用Oracle数据库在JBoss服务器(5.0)中创建DataSource的步骤.
提前致谢