modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlConnectionManager.java | 11 +++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
New commits: commit 3f1310cb5eb39890e81d5cb39f824db1afcb3884 Author: Jirka Kremser jkremser@redhat.com Date: Mon Dec 23 14:50:55 2013 +0100
Plugin validation for mysql plugin was failing because the Class.forName() statement was invoked from the constructor of the component. I moved this code to the method that actually opens the connection. This is the same strategy we use with our postgres plugin.
diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlConnectionManager.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlConnectionManager.java index 9dd60ee..6c81332 100644 --- a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlConnectionManager.java +++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlConnectionManager.java @@ -42,11 +42,6 @@ class MySqlConnectionManager {
private MySqlConnectionManager() { connections = new HashMap<MySqlConnectionInfo,Connection>(); - try { - Class.forName("com.mysql.jdbc.Driver").newInstance(); - } catch (Exception ex) { - logger.error("Unable to find com.mysql.jdbc.Driver"); - } }
static MySqlConnectionManager getConnectionManager() { @@ -93,6 +88,12 @@ class MySqlConnectionManager { }
Connection getConnection (MySqlConnectionInfo info) throws SQLException { + try { + Class.forName("com.mysql.jdbc.Driver"); + } catch (Exception ex) { + logger.error("Unable to find com.mysql.jdbc.Driver"); + } + Connection conn = connections.get(info); String url = info.buildURL(); if (conn == null) {