mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed Logging error on osgi
This commit is contained in:
@@ -43,7 +43,7 @@ import com.alibaba.druid.support.logging.LogFactory;
|
||||
|
||||
public class MockDriver implements Driver, MockDriverMBean {
|
||||
|
||||
private final static Log LOG = LogFactory.getLog(MockDriver.class);
|
||||
private static Log LOG;
|
||||
|
||||
public final static MockExecuteHandler DEFAULT_HANDLER = new MySqlMockExecuteHandlerImpl();
|
||||
|
||||
@@ -75,6 +75,14 @@ public class MockDriver implements Driver, MockDriverMBean {
|
||||
return logExecuteQueryEnable;
|
||||
}
|
||||
|
||||
private static Log getLog() {
|
||||
if (LOG == null) {
|
||||
LOG = LogFactory.getLog(MockDriver.class);
|
||||
}
|
||||
|
||||
return LOG;
|
||||
}
|
||||
|
||||
public void setLogExecuteQueryEnable(boolean logExecuteQueryEnable) {
|
||||
this.logExecuteQueryEnable = logExecuteQueryEnable;
|
||||
}
|
||||
@@ -119,8 +127,8 @@ public class MockDriver implements Driver, MockDriverMBean {
|
||||
|
||||
connections.remove(conn);
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("conn-" + conn.getId() + " close");
|
||||
if (getLog().isDebugEnabled()) {
|
||||
getLog().debug("conn-" + conn.getId() + " close");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,12 +144,12 @@ public class MockDriver implements Driver, MockDriverMBean {
|
||||
mbeanServer.registerMBean(instance, objectName);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOG.error("register druid-driver mbean error", ex);
|
||||
getLog().error("register druid-driver mbean error", ex);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
LOG.error("registerDriver error", e);
|
||||
getLog().error("registerDriver error", e);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -175,8 +183,8 @@ public class MockDriver implements Driver, MockDriverMBean {
|
||||
|
||||
MockConnection conn = createMockConnection(this, url, info);
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("connect, url " + url + ", id " + conn.getId());
|
||||
if (getLog().isDebugEnabled()) {
|
||||
getLog().debug("connect, url " + url + ", id " + conn.getId());
|
||||
}
|
||||
|
||||
if (url == null) {
|
||||
@@ -234,14 +242,14 @@ public class MockDriver implements Driver, MockDriverMBean {
|
||||
public boolean jdbcCompliant() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public MockResultSet createMockResultSet(MockStatementBase stmt) {
|
||||
return new MockResultSet(stmt);
|
||||
}
|
||||
|
||||
public ResultSet executeQuery(MockStatementBase stmt, String sql) throws SQLException {
|
||||
if (logExecuteQueryEnable && LOG.isDebugEnabled()) {
|
||||
LOG.debug("executeQuery " + sql);
|
||||
if (logExecuteQueryEnable && getLog().isDebugEnabled()) {
|
||||
getLog().debug("executeQuery " + sql);
|
||||
}
|
||||
|
||||
MockConnection conn = stmt.getConnection();
|
||||
|
||||
Reference in New Issue
Block a user