This commit is contained in:
wenshao
2011-12-09 13:46:59 +08:00
parent 05e15e9f61
commit bcc6722b50
3 changed files with 82 additions and 32 deletions
@@ -99,7 +99,7 @@ public class HADataSource extends MultiDataSource implements HADataSourceMBean,
masterConnectCount.incrementAndGet();
}
if (slave.isEnable()) {
if (conn == null && slave.isEnable()) {
conn = slave.getConnection();
slaveConnectCount.incrementAndGet();
}
@@ -579,6 +579,26 @@ public class MultiDataSourceConnection extends WrapperAdapter implements Connect
public Date getConnectedTime() {
return connectedTime;
}
public boolean isWrapperFor(Class<?> iface) throws SQLException {
boolean result = super.isWrapperFor(iface);
if (result == false && conn != null) {
result = conn.isWrapperFor(iface);
}
return result;
}
public <T> T unwrap(Class<T> iface) throws SQLException {
T object = super.unwrap(iface);
if (object == null && conn != null) {
object = conn.unwrap(iface);
}
return object;
}
public void setSchema(String schema) throws SQLException {
throw new SQLFeatureNotSupportedException();