public final class util
extends java.lang.Object
implements java.security.PrivilegedAction<java.lang.String>
JDBCDisplayUtil
Modifier and Type | Field and Description |
---|---|
private static java.lang.Class[] |
INT_P |
private java.lang.String |
key |
private static java.lang.String[][] |
protocolDrivers |
private static java.lang.Class[] |
STRING_P |
Modifier | Constructor and Description |
---|---|
private |
util() |
Modifier and Type | Method and Description |
---|---|
static void |
DisplayMulti(LocalizedOutput out,
java.sql.PreparedStatement ps,
java.sql.ResultSet rs,
java.sql.Connection conn)
Display a statement that takes parameters by
stuffing it with rows from the result set and
displaying each result each time through.
|
static void |
DisplayVector(LocalizedOutput out,
java.util.Vector v)
Display a vector of strings to the out stream.
|
static java.lang.String |
getArg(java.lang.String param,
java.lang.String[] args)
Find the argument that follows the specified parameter.
|
static java.sql.Connection |
getDataSourceConnection(java.lang.String dsName,
java.lang.String user,
java.lang.String password,
java.lang.String dbName,
boolean firstTime)
Returns a connection obtained using the DataSource.
|
static java.lang.String |
getFileArg(java.lang.String[] args)
Return the name of the ij command file or null if none is
specified.
|
static java.lang.String |
getInputResourceNameArg(java.lang.String[] args)
Return the name of a resource containing input commands or
null iff none has been specified.
|
static boolean |
getPropertyArg(java.lang.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.
|
(package private) static java.io.InputStream |
getResourceAsStream(java.lang.String resourceName)
Convenience routine to get a resource as a BufferedInputStream.
|
static java.lang.String |
getSelectedSchema(java.sql.Connection theConnection)
Selects the current schema from the given connection.
|
(package private) static java.lang.String |
getSystemProperty(java.lang.String propertyName) |
static boolean |
invalidArgs(java.lang.String[] args)
Verify the ij line arguments command arguments.
|
private static boolean |
isJCCFramework()
Used to determine if this is a JCC testing framework
So that retrieveMessages can be sent.
|
(package private) static void |
loadDriver(java.lang.String driverClass)
Load a driver given a class name.
|
static void |
loadDriverIfKnown(java.lang.String jdbcProtocol)
Find the appropriate driver and load it, given a JDBC URL.
|
private static void |
loadWithTrimmedValues(java.io.InputStream iStr,
java.util.Properties prop)
Read a set of properties from the received input stream, strip
off any excess white space that exists in those property values,
and then add those newly-read properties to the received
Properties object; not explicitly removing the whitespace here can
lead to problems.
|
(package private) static java.lang.String |
qualifyResourceName(java.lang.String resourceName,
boolean absolute)
Convenience routine to qualify a resource name with "ij.defaultPackageName"
if it is not qualified (does not begin with a "/").
|
java.lang.String |
run() |
static void |
setupDataSource(java.lang.Object ds,
java.lang.String dbName,
boolean firstTime)
Sets up a data source with values specified in ij.dataSource.* properties or
passed as parameters of this method
|
static java.sql.Connection |
startJBMS()
Utility interface that defaults driver and database to null.
|
static java.sql.Connection |
startJBMS(java.lang.String defaultDriver,
java.lang.String defaultURL)
Utility interface that defaults connInfo to null
|
static java.sql.Connection |
startJBMS(java.lang.String defaultDriver,
java.lang.String defaultURL,
java.util.Properties connInfo)
This will look for the System properties "ij.driver" and "ij.database"
and return a java.sql.Connection if it successfully connects.
|
static java.util.Properties |
updateConnInfo(java.lang.String user,
java.lang.String password,
java.util.Properties connInfo) |
(package private) static void |
Usage(LocalizedOutput out)
print a usage message for invocations of main().
|
private static final java.lang.Class[] STRING_P
private static final java.lang.Class[] INT_P
private java.lang.String key
private static final java.lang.String[][] protocolDrivers
public static java.lang.String getArg(java.lang.String param, java.lang.String[] args)
param
- the parameter (e.g. "-p")args
- the argument list to consider.public static boolean getPropertyArg(java.lang.String[] args) throws java.io.IOException
getPropertyArg will look at the args and take out a "-p
If there was a -p without a following
args
- the argument list to consider.java.io.IOException
- thrown if file not foundstatic java.lang.String qualifyResourceName(java.lang.String resourceName, boolean absolute)
absolute
- true means return null if the name is not absolute and false
means return partial names.static java.io.InputStream getResourceAsStream(java.lang.String resourceName)
resourceName
- the name of the resourcepublic static java.lang.String getFileArg(java.lang.String[] args) throws java.io.IOException
This should only be called after calling invalidArgs.
If there is no such argument, a null is returned.
args
- the argument list to consider.java.io.IOException
- thrown if file not foundpublic static java.lang.String getInputResourceNameArg(java.lang.String[] args)
public static boolean invalidArgs(java.lang.String[] args)
static void Usage(LocalizedOutput out)
public static void setupDataSource(java.lang.Object ds, java.lang.String dbName, boolean firstTime) throws java.lang.Exception
ds
- DataSource objectdbName
- Database NamefirstTime
- 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.java.lang.Exception
public static java.sql.Connection getDataSourceConnection(java.lang.String dsName, java.lang.String user, java.lang.String password, java.lang.String dbName, boolean firstTime) throws java.sql.SQLException
dsName
- Data Source nameuser
- User namepassword
- PassworddbName
- Database NamefirstTime
- Indicates if the method is called first time. This is passed to setupDataSource
method.java.sql.SQLException
public static java.sql.Connection startJBMS(java.lang.String defaultDriver, java.lang.String defaultURL, java.util.Properties connInfo) throws java.sql.SQLException, java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
If no connection was possible, it will return a null.
Failure to load the driver class is quietly ignored.
defaultDriver
- the driver to use if no property value founddefaultURL
- the database URL to use if no property value foundconnInfo
- Connection attributes to pass to getConnectionjava.sql.SQLException
- on failure to connect.java.lang.ClassNotFoundException
- on failure to load driver.java.lang.InstantiationException
- on failure to load driver.java.lang.IllegalAccessException
- on failure to load driver.java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
public static java.util.Properties updateConnInfo(java.lang.String user, java.lang.String password, java.util.Properties connInfo)
public static java.sql.Connection startJBMS() throws java.sql.SQLException, java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
java.sql.SQLException
- on failure to connect.java.lang.ClassNotFoundException
- on failure to load driver.java.lang.InstantiationException
- on failure to load driver.java.lang.IllegalAccessException
- on failure to load driver.java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
public static java.sql.Connection startJBMS(java.lang.String defaultDriver, java.lang.String defaultURL) throws java.sql.SQLException, java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
defaultDriver
- the driver to use if no property value founddefaultURL
- the database URL to use if no property value foundjava.sql.SQLException
- on failure to connect.java.lang.ClassNotFoundException
- on failure to load driver.java.lang.InstantiationException
- on failure to load driver.java.lang.IllegalAccessException
- on failure to load driver.java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
public static void DisplayVector(LocalizedOutput out, java.util.Vector v)
public static void DisplayMulti(LocalizedOutput out, java.sql.PreparedStatement ps, java.sql.ResultSet rs, java.sql.Connection conn) throws java.sql.SQLException, ijException
java.sql.SQLException
- thrown on db errorijException
- thrown on ij errorstatic final java.lang.String getSystemProperty(java.lang.String propertyName)
public final java.lang.String run()
run
in interface java.security.PrivilegedAction<java.lang.String>
private static void loadWithTrimmedValues(java.io.InputStream iStr, java.util.Properties prop) throws java.io.IOException
iStr
- An input stream from which the new properties are to be
loaded (should already be initialized).prop
- A set of properties to which the properties from
iStr will be added (should already be initialized).
Copied here to avoid dependency on an engine class.java.io.IOException
public static void loadDriverIfKnown(java.lang.String jdbcProtocol) throws java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
jdbcProtocol
- the protocol to try.java.lang.ClassNotFoundException
- if unable to
locate class for driver.java.lang.InstantiationException
- if unable to
create an instance.java.lang.IllegalAccessException
- if driver class constructor not visible.java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
static void loadDriver(java.lang.String driverClass) throws java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
java.lang.ClassNotFoundException
- if unable to
locate class for driver.java.lang.InstantiationException
- if unable to
create an instance.java.lang.IllegalAccessException
- if driver class constructor not visible.java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
private static boolean isJCCFramework()
public static java.lang.String getSelectedSchema(java.sql.Connection theConnection) throws java.sql.SQLException
theConnection
- Connection to get current schema forjava.sql.SQLException
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.