From 6934615b9736d0a777ce7f6933129ea1cdd2dd23 Mon Sep 17 00:00:00 2001 From: Warren Levy Date: Fri, 1 Dec 2000 01:48:34 +0000 Subject: Array.java: New file from classpath. * Array.java: New file from classpath. * BatchUpdateException.java: Ditto. * Blob.java: Ditto. * Clob.java: Ditto. * Ref.java: Ditto. * SQLData.java: Ditto. * SQLInput.java: Ditto. * SQLOutput.java: Ditto. * Struct.java: Ditto. * CallableStatement.java: Merged file from claspath. * Connection.java: Ditto. * DataTruncation.java: Ditto. * DatabaseMetaData.java: Ditto. * DriverManager.java: Ditto. * PreparedStatement.java: Ditto. * ResultSet.java: Ditto. * ResultSetMetaData.java: Ditto. * SQLException.java: Ditto. * SQLWarning.java: Ditto. * Statement.java: Ditto. * Types.java: Ditto. From-SVN: r37906 --- libjava/java/sql/DriverManager.java | 63 +++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 6 deletions(-) (limited to 'libjava/java/sql/DriverManager.java') diff --git a/libjava/java/sql/DriverManager.java b/libjava/java/sql/DriverManager.java index 3612783..19d4e9d 100644 --- a/libjava/java/sql/DriverManager.java +++ b/libjava/java/sql/DriverManager.java @@ -1,5 +1,5 @@ /* DriverManager.java -- Manage JDBC drivers - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -138,6 +138,38 @@ setLoginTimeout(int login_timeout) /*************************************************************************/ /** + * This method returns the log writer being used by all JDBC drivers. + * This method should be used in place of the deprecated + * getLogStream method. + * + * @return The log writer in use by JDBC drivers. + */ +public static PrintWriter +getLogWriter() +{ + return(log_writer); +} + +/*************************************************************************/ + +/** + * This method sets the log writer being used by JDBC drivers. This is a + * system-wide parameter that affects all drivers. Note that since there + * is no way to retrieve a PrintStream from a + * PrintWriter, this method cannot set the log stream in + * use by JDBC. Thus any older drivers may not see this setting. + * + * @param log_writer The new log writer for JDBC. + */ +public static void +setLogWriter(PrintWriter log_writer) +{ + DriverManager.log_writer = log_writer; +} + +/*************************************************************************/ + +/** * This method returns the log stream in use by JDBC. * * @return The log stream in use by JDBC. @@ -186,9 +218,11 @@ println(String str) * called by the driver itself in a static initializer. * * @param driver The new Driver to add. + * + * @exception SQLException If an error occurs. */ public static void -registerDriver(Driver driver) +registerDriver(Driver driver) throws SQLException { if (!drivers.contains(driver)) drivers.addElement(driver); @@ -200,9 +234,11 @@ registerDriver(Driver driver) * This method de-registers a driver from the manager. * * @param driver The Driver to unregister. + * + * @exception SQLException If an error occurs. */ public static void -deregisterDriver(Driver driver) +deregisterDriver(Driver driver) throws SQLException { if (drivers.contains(driver)) drivers.removeElement(driver); @@ -211,15 +247,30 @@ deregisterDriver(Driver driver) /*************************************************************************/ /** - * This method returns a list of all the currently loaded JDBC drivers which - * the current caller has access to. + * This method returns a list of all the currently registered JDBC drivers + * that were loaded by the current ClassLoader. * * @return An Enumeration of all currently loaded JDBC drivers. */ public static Enumeration getDrivers() { - return(drivers.elements()); + Vector v = new Vector(); + Enumeration e = drivers.elements(); + + // Is this right? + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + + while(e.hasMoreElements()) + { + Object obj = e.nextElement(); + if (!obj.getClass().getClassLoader().equals(cl)) + continue; + + v.addElement(obj); + } + + return(v.elements()); } /*************************************************************************/ -- cgit v1.1