Github user rhtyd commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1574#discussion_r65159171 --- Diff: framework/db/src/com/cloud/utils/db/DriverLoader.java --- @@ -0,0 +1,49 @@ +package com.cloud.utils.db; + +import com.cloud.utils.exception.CloudRuntimeException; +import org.apache.log4j.Logger; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DriverLoader { + + private static final Logger s_logger = Logger.getLogger(DriverLoader.class.getName()); + private static List<String> s_loadedDrivers; + private static Map<String, String> s_drivers; + + static { + s_drivers = new HashMap<String, String>(); + s_drivers.put("jdbc:mysql", "com.mysql.jdbc.Driver"); + s_drivers.put("jdbc:postgresql", "org.postgresql.Driver"); + s_drivers.put("jdbc:h2", "org.h2.Driver"); + + s_loadedDrivers = new ArrayList<String>(); + } + + + public static void loadDriver(String dbDriver) { + String driverClass = s_drivers.get(dbDriver); + if (driverClass == null) { + s_logger.error("DB driver type " + dbDriver + " is not supported!"); + throw new CloudRuntimeException("DB driver type " + dbDriver + " is not supported!"); + } + + if (s_loadedDrivers.contains(dbDriver)) { + s_logger.debug("DB driver " + driverClass + " was already loaded."); + return; + } + + try { + Class.forName(driverClass).newInstance(); + s_loadedDrivers.add(dbDriver); + s_logger.debug("Successfully loaded DB driver " + driverClass); --- End diff -- add a check to call debug if it's enabled.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---