public synchronized void log(String message, Level level) { if (level.intValue() >= currentLevel.intValue()) { String str = String.format("%s <%s> %s: %s", DATE_FORMAT.format(new Date()), level.getName(), key, message); DriverManager.println(str); } }
public synchronized void log(String message, Level level) { if (level.intValue() >= currentLevel.intValue()) { String str = String.format("%s <%s> %s: %s", DATE_FORMAT.format(new Date()), level.getName(), key, message); DriverManager.println(str); } }
private static Driver registerDriver(String className) throws SQLException { Driver d=null; try { d=(Driver) Class.forName(className).newInstance(); DriverManager.registerDriver(d); } catch (Exception e){ String message="MonProxy-Exception: loading JDBC Driver="+e.getMessage(); MonitorFactory.add(new MonKeyImp(message, e.getMessage(), "Exception"),1); // MonitorFactory.add(message, "Exception",1); DriverManager.println(message); throw new SQLException("Can not load real driver ("+className+") from JAMonDriver: "+e.getLocalizedMessage()); } return d; }
private static Driver registerDriver(String className) throws SQLException { Driver d=null; try { d=(Driver) Class.forName(className).newInstance(); DriverManager.registerDriver(d); } catch (Exception e){ String message="MonProxy-Exception: loading JDBC Driver="+e.getMessage(); MonitorFactory.add(new MonKeyImp(message, new Object[]{message, Misc.getExceptionTrace(e)}, "Exception"),1); DriverManager.println(message); throw new SQLException("Can not load real driver ("+className+") from JAMonDriver: "+e.getLocalizedMessage()); } return d; }
/** * Registers the driver as JDBC driver. * <p> * Because the implementation how the {@link DriverManager} finds the * corresponding driver for a given JDBC-URL is a little stupid - it tries * out all drivers if it can work with the URL. In case of problems (e.g. if * the network is down) it throws the first {@link SQLException} it got and * rethrow it - but this may be not the reason for the error message that * the protocoll "jdbc:proxy:..." can not be understood. * </p> * <p> * This is the reason why first all registered drivers are first * deregistered and the registered again. This guarantees that the * ProxyDriver is the first registered driver. * </p> */ public static void register() { Driver driver = new ProxyDriver(); try { Set<Driver> deregistered = deregisterDrivers(); DriverManager.registerDriver(driver); registerDrivers(deregistered); LOG.debug("{} successful registered as JDBC driver.", driver); } catch (SQLException ex) { DriverManager.println("Cannot register " + driver + " because of " + ex.getMessage() + "."); LOG.error("Cannot register {} as JDBC driver.", driver, ex); } }