aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/sql/DriverManager.java
diff options
context:
space:
mode:
authorWarren Levy <warrenl@cygnus.com>2000-12-01 01:48:34 +0000
committerWarren Levy <warrenl@gcc.gnu.org>2000-12-01 01:48:34 +0000
commit6934615b9736d0a777ce7f6933129ea1cdd2dd23 (patch)
tree7c67e6325a21b9cf53bbdc5648f2e7523a514436 /libjava/java/sql/DriverManager.java
parent95ac07b0f4d9916c7a850e3b427cbc768819d742 (diff)
downloadgcc-6934615b9736d0a777ce7f6933129ea1cdd2dd23.zip
gcc-6934615b9736d0a777ce7f6933129ea1cdd2dd23.tar.gz
gcc-6934615b9736d0a777ce7f6933129ea1cdd2dd23.tar.bz2
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
Diffstat (limited to 'libjava/java/sql/DriverManager.java')
-rw-r--r--libjava/java/sql/DriverManager.java63
1 files changed, 57 insertions, 6 deletions
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
+ * <code>getLogStream</code> 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 <code>PrintStream</code> from a
+ * <code>PrintWriter</code>, 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 <code>Driver</code> 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 <code>Driver</code> 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 <code>ClassLoader</code>.
*
* @return An <code>Enumeration</code> 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());
}
/*************************************************************************/