コード例 #1
0
ファイル: C3P0Registry.java プロジェクト: hunter129/c3p0
  static {
    classNamesToConnectionTesters.put(
        C3P0Defaults.connectionTesterClassName(), C3P0Defaults.connectionTester());

    String userManagementCoordinator = C3P0ConfigUtils.getPropsFileConfigProperty(MC_PARAM);
    if (userManagementCoordinator != null) {
      try {
        mc = (ManagementCoordinator) Class.forName(userManagementCoordinator).newInstance();
      } catch (Exception e) {
        if (logger.isLoggable(MLevel.WARNING))
          logger.log(
              MLevel.WARNING,
              "Could not instantiate user-specified ManagementCoordinator "
                  + userManagementCoordinator
                  + ". Using NullManagementCoordinator (c3p0 JMX management disabled!)",
              e);
        mc = new NullManagementCoordinator();
      }
    } else {
      try {
        Class.forName("java.lang.management.ManagementFactory");

        mc =
            (ManagementCoordinator)
                Class.forName("com.mchange.v2.c3p0.management.ActiveManagementCoordinator")
                    .newInstance();
      } catch (Exception e) {
        if (logger.isLoggable(MLevel.INFO))
          logger.log(
              MLevel.INFO, "jdk1.5 management interfaces unavailable... JMX support disabled.", e);
        mc = new NullManagementCoordinator();
      }
    }
  }
コード例 #2
0
ファイル: C3P0Registry.java プロジェクト: hunter129/c3p0
 public static ConnectionTester getConnectionTester(String className) {
   try {
     ConnectionTester out = (ConnectionTester) classNamesToConnectionTesters.get(className);
     if (out == null) {
       out = (ConnectionTester) Class.forName(className).newInstance();
       classNamesToConnectionTesters.put(className, out);
     }
     return out;
   } catch (Exception e) {
     if (logger.isLoggable(MLevel.WARNING))
       logger.log(
           MLevel.WARNING,
           "Could not create for find ConnectionTester with class name '"
               + className
               + "'. Using default.",
           e);
     return C3P0Defaults.connectionTester();
   }
 }
コード例 #3
0
ファイル: C3P0Registry.java プロジェクト: hunter129/c3p0
 public static ConnectionCustomizer getConnectionCustomizer(String className) throws SQLException {
   if (className == null) return null;
   else {
     try {
       ConnectionCustomizer out =
           (ConnectionCustomizer) classNamesToConnectionCustomizers.get(className);
       if (out == null) {
         out = (ConnectionCustomizer) Class.forName(className).newInstance();
         classNamesToConnectionCustomizers.put(className, out);
       }
       return out;
     } catch (Exception e) {
       if (logger.isLoggable(MLevel.WARNING))
         logger.log(
             MLevel.WARNING,
             "Could not create for find ConnectionCustomizer with class name '" + className + "'.",
             e);
       throw SqlUtils.toSQLException(e);
     }
   }
 }