| java.lang.Object org.apache.derby.impl.tools.ij.util
Method Summary | |
public static void | DisplayMulti(LocalizedOutput out, PreparedStatement ps, ResultSet rs, Connection conn) Display a statement that takes parameters by
stuffing it with rows from the result set and
displaying each result each time through. | public static void | DisplayVector(LocalizedOutput out, Vector v) Display a vector of strings to the out stream. | static void | Usage(LocalizedOutput out) print a usage message for invocations of main(). | public static String | getArg(String param, String[] args) Find the argument that follows the specified parameter.
Parameters: param - the parameter (e.g. | public static Properties | getConnAttributeArg(String[] args) ij is started with "-ca[r] file OtherArgs";
the file contains connection attibute properties
to pass to getConnection
getConnAttributeArg will look at the args and take out a
"-ca[r] " pair and returning the Properties
exception: IOException - thrown if file not found Parameters: args - the argument list to consider. | public static Connection | getDataSourceConnection(String dsName, String user, String password, String dbName, boolean firstTime) Returns a connection obtained using the DataSource. | public static String | getFileArg(String[] args) Return the name of the ij command file or null if none is
specified. | public static String | getInputResourceNameArg(String[] args) Return the name of a resource containing input commands or
null iff none has been specified. | public static boolean | getPropertyArg(String[] args) ij is started with "-p[r] file OtherArgs";
the file contains properties to control the driver and database
used to run ij, and can provide additional system properties.
getPropertyArg will look at the args and take out a "-p " pair,
reading the file into the system properties.
If there was a -p without a following , no action is taken.
exception: IOException - thrown if file not found Parameters: args - the argument list to consider. | public static InputStream | getResourceAsStream(String resourceName) Convenience routine to get a resource as a BufferedInputStream. | public static String | getSelectedSchema(Connection theConnection) Selects the current schema from the given connection. | final static String | getSystemProperty(String propertyName) | public static boolean | invalidArgs(String[] args) Verify the ij line arguments command arguments. | public static void | loadDriver(String driverClass) Load a driver given a class name. | public static void | loadDriverIfKnown(String jdbcProtocol) Find the appropriate driver and load it, given a JDBC URL. | static String | qualifyResourceName(String resourceName, boolean absolute) Convenience routine to qualify a resource name with "ij.defaultPackageName"
if it is not qualified (does not begin with a "/").
Parameters: absolute - true means return null if the name is not absolute and falsemeans return partial names. | final public Object | run() | public static void | setupDataSource(Object ds, String dbName, boolean firstTime) Sets up a data source with values specified in ij.dataSource.* properties or
passed as parameters of this method
Parameters: ds - DataSource object Parameters: dbName - Database Name Parameters: firstTime - If firstTime is false, ij.dataSource.createDatabase and ij.dataSource.databaseName properties will not be used. | public static Connection | startJBMS(String defaultDriver, String defaultURL, Properties connInfo) This will look for the System properties "ij.driver" and "ij.database"
and return a java.sql.Connection if it successfully connects. | public static Connection | startJBMS() Utility interface that defaults driver and database to null. | public static Connection | startJBMS(String defaultDriver, String defaultURL) | public static Properties | updateConnInfo(String user, String password, Properties connInfo) |
getArg | public static String getArg(String param, String[] args)(Code) | | Find the argument that follows the specified parameter.
Parameters: param - the parameter (e.g. "-p") Parameters: args - the argument list to consider. the argument that follows the parameter, or null if not found |
getConnAttributeArg | public static Properties getConnAttributeArg(String[] args) throws IOException(Code) | | ij is started with "-ca[r] file OtherArgs";
the file contains connection attibute properties
to pass to getConnection
getConnAttributeArg will look at the args and take out a
"-ca[r] " pair and returning the Properties
exception: IOException - thrown if file not found Parameters: args - the argument list to consider. properties in the file |
getDataSourceConnection | public static Connection getDataSourceConnection(String dsName, String user, String password, String dbName, boolean firstTime) throws SQLException(Code) | | Returns a connection obtained using the DataSource. This method will be called when ij.dataSource
property is set. It uses ij.dataSource.* properties to get details for the connection.
Parameters: dsName - Data Source name Parameters: user - User name Parameters: password - Password Parameters: dbName - Database Name Parameters: firstTime - Indicates if the method is called first time. This is passed to setupDataSource method. throws: SQLException - |
getFileArg | public static String getFileArg(String[] args) throws IOException(Code) | | Return the name of the ij command file or null if none is
specified. The command file may be proceeded with -f flag on
the command line. Alternatively, the command file may be
specified without a -f flag. In this case we assume the first
unknown argument is the command file.
This should only be called after calling invalidArgs.
If there is no such argument, a null is returned.
Parameters: args - the argument list to consider. the name of the first argument not preceded by "-p",null if none found. exception: IOException - thrown if file not found |
getInputResourceNameArg | public static String getInputResourceNameArg(String[] args)(Code) | | Return the name of a resource containing input commands or
null iff none has been specified.
|
getPropertyArg | public static boolean getPropertyArg(String[] args) throws IOException(Code) | | ij is started with "-p[r] file OtherArgs";
the file contains properties to control the driver and database
used to run ij, and can provide additional system properties.
getPropertyArg will look at the args and take out a "-p " pair,
reading the file into the system properties.
If there was a -p without a following , no action is taken.
exception: IOException - thrown if file not found Parameters: args - the argument list to consider. true if a property item was found and loaded. |
getResourceAsStream | public static InputStream getResourceAsStream(String resourceName)(Code) | | Convenience routine to get a resource as a BufferedInputStream. If the
resourceName is not absolute (does not begin with a "/") this qualifies
the name with the "ij.defaultResourcePackage" name.
Parameters: resourceName - the name of the resource a buffered stream for the resource if it exists and null otherwise. |
getSelectedSchema | public static String getSelectedSchema(Connection theConnection) throws SQLException(Code) | | Selects the current schema from the given connection.
As there are no way of getting current schema supported by
all major DBMS-es, this method may return null.
Parameters: theConnection - Connection to get current schema for the current schema of the connection, or null if error. |
invalidArgs | public static boolean invalidArgs(String[] args)(Code) | | Verify the ij line arguments command arguments. Also used to detect --help.
true if the args are invalid- Only legal argument provided.
- Only specify a quantity once.
|
qualifyResourceName | static String qualifyResourceName(String resourceName, boolean absolute)(Code) | | Convenience routine to qualify a resource name with "ij.defaultPackageName"
if it is not qualified (does not begin with a "/").
Parameters: absolute - true means return null if the name is not absolute and falsemeans return partial names. |
setupDataSource | public static void setupDataSource(Object ds, String dbName, boolean firstTime) throws Exception(Code) | | Sets up a data source with values specified in ij.dataSource.* properties or
passed as parameters of this method
Parameters: ds - DataSource object Parameters: dbName - Database Name Parameters: firstTime - If firstTime is false, ij.dataSource.createDatabase and ij.dataSource.databaseName properties will not be used. The value in parameter dbName will be used instead of ij.dataSource.databaseName. throws: Exception - |
startJBMS | public static Connection startJBMS(String defaultDriver, String defaultURL, Properties connInfo) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException(Code) | | This will look for the System properties "ij.driver" and "ij.database"
and return a java.sql.Connection if it successfully connects.
The deprecated driver and database properties are examined first.
If no connection was possible, it will return a null.
Failure to load the driver class is quietly ignored.
Parameters: defaultDriver - the driver to use if no property value found Parameters: defaultURL - the database URL to use if no property value found Parameters: connInfo - Connection attributes to pass to getConnection a connection to the defaultURL if possible; null if not. exception: SQLException - on failure to connect. exception: ClassNotFoundException - on failure to load driver. exception: InstantiationException - on failure to load driver. exception: IllegalAccessException - on failure to load driver. |
|
|