正确的方法是使用DelegatingDataSource
,从原始数据源中检索OracleConnection
对象,并用适当的参数调用OracleConnection.setSessionTimeZone()
。
C3P0代码如下所示:
private Object[] timeZoneArgs = new Object[] { "Europe/Berlin" };
@Override
public Connection getConnection() throws SQLException {
Connection conn = super.getConnection();
try {
final Method setSessionTimeZoneMethod = OracleConnection.class.getMethod("setSessionTimeZone", String.class);
final C3P0ProxyConnection castCon = (C3P0ProxyConnection) conn;
castCon.rawConnectionOperation(setSessionTimeZoneMethod, C3P0ProxyConnection.RAW_CONNECTION, timeZoneArgs);
return conn;
} catch (Exception e) {
log.error("setSessionTimeZone failed " + e.getMessage());
return conn;
}
}
您的意思是指哪一个环节? Oracle连接会话或HTTP会话?前者,我假设? – skaffman 2010-05-10 20:24:19
这解决了你的问题?我需要在MySQL上做同样的事情,我仍然在寻找如何做到这一点! – 2011-05-11 20:40:46
我有问题/职位留在这个DEAD模式!没有答案,没有确认,没有猜测! – 2011-05-12 14:31:28