正確的方法是使用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