Class Hierarchy        Index

Class COM.cloudscape.util.DBClassLoad

java.lang.Object
   |
   +----COM.cloudscape.util.DBClassLoad

public class DBClassLoad
extends Object
Copyright © 1998-1999, Cloudscape, Inc. All rights reserved.

Utility methods that allow application code to be stored in a database, and/or allow access to classes loaded from cloudscape.database.classpath. Similar to java.rmi.server.RMIClassLoader

See Also:
RMIClassLoader

Method Index

 o invokeMain(Connection, String, String[])
Invoke the main method of a class stored in a database, using the passed in java.sql.Connection to connect to the database.
 o invokeRun(Connection, String)
Create an instance of a class stored in a database that implements Runnable and invoke its run method, using the passed in java.sql.Connection to connect to the database.
 o loadClass(Connection, String)
Load a class from a Cloudscape system using a connection to that system.
 o main(String[])
Invoke the main method of a class stored in a Cloudscape database.

Methods

 o main
 public static void main(String args[]) throws SQLException, ClassNotFoundException, InstantiationException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, Throwable
Invoke the main method of a class stored in a Cloudscape database.
The first argument is a JDBC database connection URL to the Cloudscape database system that contains the class. It can be any database in the Cloudscape system, it need not be the databse that contains the jar that contains the class.
The second argument is the name of the class that contains the main() method to be run. This is the class that you normally use on the command line.
The remaining arguments are passed to the main() method.

java COM.cloudscape.util.DBClassLoad jdbc_url main_class_name [args ...]
replaces
java main_class_name [args ...]
e.g.
java COM.cloudscape.util.DBClassLoad jdbc:cloudscape:photsdb COM.acme.DisplayImage BayBridge.gif
instead of
java COM.acme.DisplayImage BayBridge.gif

Invoking this method results in these steps:

  1. Booting the JDBC driver (and thus Cloudscape) associated with the JDBC URL
  2. Connecting to the database using the JDBC URL
  3. Loading the class within Cloudscape
  4. Closing the connection
  5. Invoking the main method outside of Cloudscape

Note that this method will work and behave normally even if the main class is loaded from the local classes by Cloudscape and not from cloudscape.database.classpath

Throws: SQLException
Error connecting to the database, or thrown during execution of main method
Throws: ClassNotFoundException
Error loading the associated JDBC driver, or thrown during execution of main method
Throws: InstantiationException
Error loading the associated JDBC driver, or thrown during execution of main method
Throws: NoSuchMethodException
No main method exists in the class, or thrown during execution of main method
Throws: IllegalAccessException
The main method is not public, or thrown during execution of main method
Throws: IllegalArgumentException
Thrown during execution of main method
Throws: Throwable
Thrown during execution of main method
 o invokeMain
 public static void invokeMain(Connection conn,
                               String mainClassName,
                               String args[]) throws SQLException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, Throwable
Invoke the main method of a class stored in a database, using the passed in java.sql.Connection to connect to the database. The connection can be to any database in the Cloudscape system, it need not be the database that contains the jar that contains the class.

Invoking this method results in these steps:

  1. Loading the class within Cloudscape
  2. Invoking the main method outside of Cloudscape.

Note that this method will work and behave normally even if the main class is loaded from the local classes by Cloudscape and not from cloudscape.database.classpath

Throws: SQLException
Error connecting to the database, or thrown during execution of main method
Throws: NoSuchMethodException
No main method exists in the class, or thrown during execution of main method
Throws: IllegalAccessException
The main method is not public, or thrown during execution of main method
Throws: IllegalArgumentException
Thrown during execution of main method
Throws: Throwable
Thrown during execution of main method
 o invokeRun
 public static void invokeRun(Connection conn,
                              String runnableClassName) throws SQLException, InstantiationException, IllegalAccessException, ClassCastException
Create an instance of a class stored in a database that implements Runnable and invoke its run method, using the passed in java.sql.Connection to connect to the database. The connection can be to any database in the Cloudscape system, it need not be the database that contains the jar that contains the class. The class must have a public no-arg constructor.

Invoking this method results in these steps:

  1. Loading the class within Cloudscape
  2. Creating an instance of the class outside of Cloudscape.
  3. Invoking the run method of this object outside of Cloudscape.

Note that this method will work and behave normally even if the class is loaded from the local classes by Cloudscape and not from cloudscape.database.classpath

Throws: SQLException
Error connecting to the database, or thrown during execution of run method
Throws: InstantiationException
An error was thrown while creating an instance of the class
Throws: IllegalAccessException
The no-arg constructor is not public
Throws: ClassCastException
The class does not implement java.lang.Runnable
See Also:
Runnable
 o loadClass
 public static Class loadClass(Connection conn,
                               String className) throws SQLException
Load a class from a Cloudscape system using a connection to that system. The connection can be to any database in the Cloudscape system, it need not be the database that contains the jar that contains the class.

Throws: SQLException
Error connecting to the database or class does not exist.

  Class Hierarchy        Index