From 5bbf9566c8ecb45483f64c171ee163a8592134b8 Mon Sep 17 00:00:00 2001 From: wenshao Date: Thu, 2 Jun 2011 13:21:28 +0000 Subject: [PATCH] git-svn-id: http://code.alibabatech.com/svn/druid/trunk@249 b9813039-fb51-4c41-a8b9-e21c2acb5095 --- .../com/alibaba/druid/ha/HADataSource.java | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/alibaba/druid/ha/HADataSource.java b/src/main/java/com/alibaba/druid/ha/HADataSource.java index 589a69017e..0c86f74b80 100644 --- a/src/main/java/com/alibaba/druid/ha/HADataSource.java +++ b/src/main/java/com/alibaba/druid/ha/HADataSource.java @@ -12,8 +12,8 @@ public class HADataSource implements DataSource { private final List dataSources = new CopyOnWriteArrayList(); - private int loginTimeout = 0; - private PrintWriter logWriter = new PrintWriter(System.out); + private int loginTimeout = 0; + private PrintWriter logWriter = new PrintWriter(System.out); public List getDataSources() { return dataSources; @@ -40,13 +40,30 @@ public class HADataSource implements DataSource { } @Override - public T unwrap(Class iface) throws SQLException { - return null; + public boolean isWrapperFor(Class iface) throws SQLException { + if (iface == null) { + return false; + } + + if (iface.isInstance(this)) { + return true; + } + + return false; } + @SuppressWarnings("unchecked") @Override - public boolean isWrapperFor(Class iface) throws SQLException { - return false; + public T unwrap(Class iface) throws SQLException { + if (iface == null) { + return null; + } + + if (iface.isInstance(this)) { + return (T) this; + } + + return null; } @Override @@ -56,7 +73,7 @@ public class HADataSource implements DataSource { @Override public Connection getConnection(String username, String password) throws SQLException { - return null; + throw new UnsupportedOperationException(); } }