From 604735e54e289ae426dd3fa1f6961a40a44fdd46 Mon Sep 17 00:00:00 2001 From: Alexandre Chatiron Date: Tue, 6 Aug 2013 17:30:52 +0800 Subject: [PATCH] [#1099] Fix ProxiDriver in order to compile with JDK 1.7 and JDK 1.6 --- framework/src/play/db/DBPlugin.java | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/framework/src/play/db/DBPlugin.java b/framework/src/play/db/DBPlugin.java index 9fe11aec6a..9648de7098 100644 --- a/framework/src/play/db/DBPlugin.java +++ b/framework/src/play/db/DBPlugin.java @@ -1,6 +1,9 @@ package play.db; import com.mchange.v2.c3p0.ConnectionCustomizer; + +import java.sql.SQLFeatureNotSupportedException; + import play.Play; import play.PlayPlugin; import play.mvc.Http; @@ -136,13 +139,6 @@ public static class ProxyDriver implements Driver { this.driver = d; } - /* - * JDK 7 compatibility - */ - public Logger getParentLogger() { - return null; - } - public boolean acceptsURL(String u) throws SQLException { return this.driver.acceptsURL(u); } @@ -166,6 +162,17 @@ public DriverPropertyInfo[] getPropertyInfo(String u, Properties p) throws SQLEx public boolean jdbcCompliant() { return this.driver.jdbcCompliant(); } + + // Method not annotated with @Override since getParentLogger() is a new method + // in the CommonDataSource interface starting with JDK7 and this annotation + // would cause compilation errors with JDK6. + public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException { + try { + return (java.util.logging.Logger) Driver.class.getDeclaredMethod("getParentLogger").invoke(this.driver); + } catch (Throwable e) { + return null; + } + } }