java/code/src/com/redhat/rhn/common/db/RhnConnectionCustomizer.java | 73 ++++++++++
java/conf/default/rhn_hibernate.conf | 1
java/spacewalk-java.spec | 5
rel-eng/packages/spacewalk-java | 2
4 files changed, 79 insertions(+), 2 deletions(-)
New commits:
commit 237ee31c23e6941c64ce9beefd48ba2b48a31342
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Wed Mar 27 16:28:09 2013 +0100
Automatic commit of package [spacewalk-java] release [1.10.32-1].
diff --git a/java/spacewalk-java.spec b/java/spacewalk-java.spec
index c781215..3fd6d46 100644
--- a/java/spacewalk-java.spec
+++ b/java/spacewalk-java.spec
@@ -28,7 +28,7 @@ Name: spacewalk-java
Summary: Spacewalk Java site packages
Group: Applications/Internet
License: GPLv2
-Version: 1.10.31
+Version: 1.10.32
Release: 1%{?dist}
URL:
https://fedorahosted.org/spacewalk
Source0:
https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
@@ -678,6 +678,9 @@ fi
%{jardir}/postgresql-jdbc.jar
%changelog
+* Wed Mar 27 2013 Tomas Lestach <tlestach(a)redhat.com> 1.10.32-1
+- introduce RhnConnectionCustomizer
+
* Tue Mar 26 2013 Tomas Kasparek <tkasparek(a)redhat.com> 1.10.31-1
- downloading packages for kickstart via java
- correct capitalization
diff --git a/rel-eng/packages/spacewalk-java b/rel-eng/packages/spacewalk-java
index c97580b..29905c9 100644
--- a/rel-eng/packages/spacewalk-java
+++ b/rel-eng/packages/spacewalk-java
@@ -1 +1 @@
-1.10.31-1 java/
+1.10.32-1 java/
commit 6e364cdc122ce4c0376199c7ba093b9a3af88a1a
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Wed Mar 27 10:32:59 2013 +0100
introduce RhnConnectionCustomizer
addressing:
java.sql.SQLException: Session Time Zone not set!
with oicv10
diff --git a/java/code/src/com/redhat/rhn/common/db/RhnConnectionCustomizer.java
b/java/code/src/com/redhat/rhn/common/db/RhnConnectionCustomizer.java
new file mode 100644
index 0000000..82d3575
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/common/db/RhnConnectionCustomizer.java
@@ -0,0 +1,73 @@
+/**
+ * Copyright (c) 2013 Red Hat, Inc.
+ *
+ * This software is licensed to you under the GNU General Public License,
+ * version 2 (GPLv2). There is NO WARRANTY for this software, express or
+ * implied, including the implied warranties of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+ * along with this software; if not, see
+ *
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * Red Hat trademarks are not licensed under GPLv2. No permission is
+ * granted to use or replicate Red Hat trademarks that are incorporated
+ * in this software or its documentation.
+ */
+package com.redhat.rhn.common.db;
+
+import com.redhat.rhn.common.conf.ConfigDefaults;
+
+import com.mchange.v2.c3p0.ConnectionCustomizer;
+
+import org.apache.log4j.Logger;
+
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.util.TimeZone;
+/**
+ * RhnConnectionCustomizer
+ * @version $Rev$
+ */
+public class RhnConnectionCustomizer implements ConnectionCustomizer {
+
+ private static final Logger LOG = Logger.getLogger(RhnConnectionCustomizer.class);
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onAcquire(Connection c, String pdsIdt) throws Exception {
+ if (ConfigDefaults.get().isOracle()) {
+ try {
+ Method setSessionTimeZoneMethod = Class.forName(
+ "oracle.jdbc.driver.OracleConnection").getMethod(
+ "setSessionTimeZone", String.class);
+ if (setSessionTimeZoneMethod != null) {
+ setSessionTimeZoneMethod.invoke(c, TimeZone.getDefault().getID());
+ }
+ }
+ catch (Exception e) {
+ LOG.warn("Failed to set session time zone.");
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onCheckIn(Connection c, String pdsIdt) throws Exception {
+ // empty
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onCheckOut(Connection c, String pdsIdt) throws Exception {
+ // empty
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onDestroy(Connection c, String pdsIdt) throws Exception {
+ // empty
+ }
+}
diff --git a/java/conf/default/rhn_hibernate.conf b/java/conf/default/rhn_hibernate.conf
index fc6ba19..c3f052d 100644
--- a/java/conf/default/rhn_hibernate.conf
+++ b/java/conf/default/rhn_hibernate.conf
@@ -27,6 +27,7 @@ hibernate.c3p0.max_statements=0
# test period value in seconds
hibernate.c3p0.idle_test_period=300
hibernate.c3p0.testConnectionOnCheckout=true
+hibernate.c3p0.connectionCustomizerClassName=com.redhat.rhn.common.db.RhnConnectionCustomizer
hibernate.cache.provider_class=org.hibernate.cache.OSCacheProvider
hibernate.cache.use_query_cache=true