public final class util extends Object implements PrivilegedAction
JDBCDisplayUtil| Modifier and Type | Method and Description |
|---|---|
static void |
DisplayMulti(com.pivotal.gemfirexd.internal.iapi.tools.i18n.LocalizedOutput out,
PreparedStatement ps,
ResultSet rs,
Connection conn,
scala.tools.jline.console.ConsoleReader reader,
com.pivotal.gemfirexd.internal.shared.common.StopWatch timer)
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(com.pivotal.gemfirexd.internal.iapi.tools.i18n.LocalizedOutput out,
Vector v)
Display a vector of strings to the out stream.
|
static String |
getArg(String param,
String[] args)
Find the argument that follows the specified parameter.
|
static Properties |
getConnAttributeArg(String[] args)
ij is started with "-ca[r] file OtherArgs";
the file contains connection attibute properties
to pass to getConnection
|
static Connection |
getDataSourceConnection(String dsName,
String user,
String password,
String dbName,
boolean firstTime)
Returns a connection obtained using the DataSource.
|
static String |
getFileArg(String[] args)
Return the name of the ij command file or null if none is
specified.
|
static String |
getInputResourceNameArg(String[] args)
Return the name of a resource containing input commands or
null iff none has been specified.
|
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.
|
static InputStream |
getResourceAsStream(String resourceName)
Convenience routine to get a resource as a BufferedInputStream.
|
static String |
getSelectedSchema(Connection theConnection)
Selects the current schema from the given connection.
|
static boolean |
invalidArgs(String[] args)
Verify the ij line arguments command arguments.
|
static void |
loadDriver(String driverClass)
Load a driver given a class name.
|
static void |
loadDriverIfKnown(String jdbcProtocol)
Find the appropriate driver and load it, given a JDBC URL.
|
Object |
run() |
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
|
static Connection |
startJBMS()
Utility interface that defaults driver and database to null.
|
static Connection |
startJBMS(String defaultDriver,
String defaultURL)
Utility interface that defaults connInfo to null
|
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.
|
static Properties |
updateConnInfo(String user,
String password,
Properties connInfo) |
public static String getArg(String param, String[] args)
param - the parameter (e.g. "-p")args - the argument list to consider.public static boolean getPropertyArg(String[] args) throws 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.IOException - thrown if file not foundpublic static Properties getConnAttributeArg(String[] args) throws IOException
getConnAttributeArg will look at the args and take out a
"-ca[r]
args - the argument list to consider.IOException - thrown if file not foundpublic static InputStream getResourceAsStream(String resourceName)
resourceName - the name of the resourcepublic static String getFileArg(String[] args) throws 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.IOException - thrown if file not foundpublic static String getInputResourceNameArg(String[] args)
public static boolean invalidArgs(String[] args)
public static void setupDataSource(Object ds, String dbName, boolean firstTime) throws 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.Exceptionpublic static Connection getDataSourceConnection(String dsName, String user, String password, String dbName, boolean firstTime) throws SQLException
dsName - Data Source nameuser - User namepassword - PassworddbName - Database NamefirstTime - Indicates if the method is called first time. This is passed to setupDataSource
method.SQLExceptionpublic static Connection startJBMS(String defaultDriver, String defaultURL, Properties connInfo) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException
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 getConnectionSQLException - on failure to connect.ClassNotFoundException - on failure to load driver.InstantiationException - on failure to load driver.IllegalAccessException - on failure to load driver.public static Properties updateConnInfo(String user, String password, Properties connInfo)
public static Connection startJBMS() throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException
SQLException - on failure to connect.ClassNotFoundException - on failure to load driver.InstantiationException - on failure to load driver.IllegalAccessException - on failure to load driver.public static Connection startJBMS(String defaultDriver, String defaultURL) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException
defaultDriver - the driver to use if no property value founddefaultURL - the database URL to use if no property value foundSQLException - on failure to connect.ClassNotFoundException - on failure to load driver.InstantiationException - on failure to load driver.IllegalAccessException - on failure to load driver.public static void DisplayVector(com.pivotal.gemfirexd.internal.iapi.tools.i18n.LocalizedOutput out,
Vector v)
public static void DisplayMulti(com.pivotal.gemfirexd.internal.iapi.tools.i18n.LocalizedOutput out,
PreparedStatement ps,
ResultSet rs,
Connection conn,
scala.tools.jline.console.ConsoleReader reader,
com.pivotal.gemfirexd.internal.shared.common.StopWatch timer)
throws SQLException,
ijException
SQLException - thrown on db errorijException - thrown on ij errorpublic final Object run()
run in interface PrivilegedActionpublic static void loadDriverIfKnown(String jdbcProtocol) throws ClassNotFoundException, InstantiationException, IllegalAccessException
jdbcProtocol - the protocol to try.ClassNotFoundException - if unable to
locate class for driver.InstantiationException - if unable to
create an instance.IllegalAccessException - if driver class constructor not visible.public static void loadDriver(String driverClass) throws ClassNotFoundException, InstantiationException, IllegalAccessException
ClassNotFoundException - if unable to
locate class for driver.InstantiationException - if unable to
create an instance.IllegalAccessException - if driver class constructor not visible.public static String getSelectedSchema(Connection theConnection) throws SQLException
theConnection - Connection to get current schema forSQLExceptionCopyright © 2010-2015 Pivotal Software, Inc. All rights reserved.