public class JDBCConnection extends DBConnection
The first time this class is initialized, it loads the default JDBC driver (sun.jdbc.odbc.JdbcOdbcDriver unless otherwise specified in the webMethods property, watt.server.jdbc.defaultDriver) and any other drivers that are specified by the webMethods property watt.server.jdbc.driverList.
Constructor and Description |
---|
JDBCConnection()
Deprecated.
Use JDBCConnection(String, String, String)
|
JDBCConnection(java.lang.String url,
java.lang.String user,
java.lang.String pass)
Constructs a JDBCConnection and connects it to the specified database using the default JDBC driver.
|
JDBCConnection(java.lang.String url,
java.lang.String user,
java.lang.String pass,
java.lang.String driver)
Constructs a JDBCConnection and connects it to the specified database using the specified JDBC driver.
|
Modifier and Type | Method and Description |
---|---|
Values |
call(java.lang.String proc,
Values[] sig,
Values data,
boolean paramsByOrder)
Calls the specified SQL stored procedure.
|
void |
clearTransaction()
Voids the current transaction without performing a rollback or a commit.
|
void |
close()
Closes this connection to the database.
|
void |
commit()
Permanently commits the database operations that have been performed since the last startTransaction and ends the transaction.
|
Values |
connect(java.lang.String dbUrl,
java.lang.String dbUser,
java.lang.String dbPass,
java.lang.String dbDriver)
Deprecated.
Use one of the JDBCConnection constructors.
|
Values |
execSQL(java.lang.String sql,
java.lang.Object[] paramValues,
int[] paramTypes,
boolean processEscapes)
Executes the specified SQL statement using host variables from a specified Object [] and optionally processes embedded escape sequences.
|
static java.lang.String[] |
getAvailableDrivers()
Returns a list of JDBC drivers that are currently loaded.
|
java.lang.String |
getDriverName()
Returns the name of the JDBC driver that this JDBCConnection is currently using (e.g., oracle.jdbc.driver.OracleDriver).
|
Values |
getProcInfo(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String proc)
Returns information about a stored procedure that matches the specified catalog and schema criteria.
|
Values |
getProcs(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String procNamePattern)
Returns a list of stored procedures matching the specified catalog, schema, and procedure name criteria.
|
Values |
getTableInfo(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String tableNamePattern,
java.lang.String colNamePattern)
Returns information (name, type, null value setting, and so forth) about the columns in a table matching the specified catalog, schema, and column name criteria.
|
Values |
getTables(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String tableNamePattern,
java.lang.String[] tableTypes)
Returns a list of tables matching the specified catalog, schema, table name, and table type criteria.
|
static Values |
handleSQLException(java.sql.SQLException e,
java.lang.String loc)
Converts an SQL Exception into a Values object.
|
static void |
init()
Initializes this JDBCConnection and loads the default JDBC driver and any other drivers that are configured to be preloaded if they are not loaded already.
|
boolean |
isConnected()
Indicates whether this JDBCConnection is currently connected to a database.
|
static boolean |
loadDriver(java.lang.String driver)
Loads the specified driver.
|
void |
rollback()
Reverses all database operations that have been performed since the last startTransaction and ends that transaction.
|
void |
startTransaction()
Starts a transaction.
|
static void |
toValues(java.sql.ResultSet set,
Values results)
Converts pending results into a Values object.
|
call, call, clearCatSchemDefaults, delete, execSQL, execSQL, getPassword, getProcInfo, getProcs, getTableInfo, getTables, getUrl, getUser, insert, insert, query, setCatSchemDefaults, update
public JDBCConnection()
public JDBCConnection(java.lang.String url, java.lang.String user, java.lang.String pass) throws DBConnectionException
url
- A String specifying the URL of the database to which you want to connect.user
- A String specifying the user name that is to be used to connect to the database.pass
- A String specifying the password that is to be used to connect to the database.DBConnectionException
- If a connection cannot be established.public JDBCConnection(java.lang.String url, java.lang.String user, java.lang.String pass, java.lang.String driver) throws DBConnectionException
url
- A String specifying the URL of the database to which you want to connect.user
- A String specifying the user name that is to be used to connect to the database.pass
- A String specifying the password that is to be used to connect to the database.driver
- A String specifying the name of the JDBC driver that this JDBCConnection will use to access the database (e.g., oracle.jdbc.driver.OracleDriver.DBConnectionException
- If a connection cannot be established.public static void init()
public static boolean loadDriver(java.lang.String driver)
driver
- A String specifying the name of the JDBC driver you want to load (e.g., oracle.jdbc.driver.OracleDriver).public static final java.lang.String[] getAvailableDrivers()
public boolean isConnected()
public java.lang.String getDriverName()
public Values connect(java.lang.String dbUrl, java.lang.String dbUser, java.lang.String dbPass, java.lang.String dbDriver)
dbUrl
- A String specifying the URL of the database to which you want to connect.dbUser
- A String specifying the user name that is to be used to connect to the database.dbPass
- A String specifying the password that is to be used to connect to the database.dbDriver
- A String specifying the name of the JDBC driver that is to be used to access the database (e.g., oracle.jdbc.driver.OracleDriver).public void close()
close
in class DBConnection
public void startTransaction() throws DBException
startTransaction
in class DBConnection
DBException
- If the database returns an error (most likely, because it doesn't support transaction processing).commit()
,
rollback()
,
clearTransaction()
public void commit() throws DBException
commit
in class DBConnection
DBException
- If the database returns an error. This can happen if the database doesn't support transaction processing or if a transaction was never started.rollback()
,
startTransaction()
public void rollback() throws DBException
rollback
in class DBConnection
DBException
- If the database returns an error. This can happen if the database doesn't support transaction processing or if a transaction was never started.commit()
,
startTransaction()
public void clearTransaction()
clearTransaction
in class DBConnection
startTransaction()
,
commit()
,
rollback()
public Values call(java.lang.String proc, Values[] sig, Values data, boolean paramsByOrder)
call
in class DBConnection
proc
- A String specifying the name of the stored procedure.sig
- A Values [] in which each member contains the following keys:
Key |
Value |
name | The name of the parameter ("RETURN_VALUE" for the return val). |
sqlType | The parameter's SQL type (e.g. "VARCHAR") |
direction | The parameter's purpose, which must be one of the following: in out inout return value |
Note: If you do not specify sig, the JDBC version will use DatabaseMetaData to retrieve parameter information and make the call.
data
- A Values object containing the parameter values that are to be passed to the procedure.paramsByOrder
- A boolean specifying whether parameter values are to be retrieved from data by order or name.
Set paramsByOrder to… |
To… |
true | Access parameters by order |
false | Access parameters by name |
public Values execSQL(java.lang.String sql, java.lang.Object[] paramValues, int[] paramTypes, boolean processEscapes)
execSQL
in class DBConnection
sql
- A String specifying the SQL statement that you want to execute. (No parsing or checking of this string is performed.)paramValues
- An Object [] containing the values that will be assigned to the host variables ('?'s) in the SQL statement.paramTypes
- A String [] specifying the SQL data types in of the objects in paramValues (using JDBC 1.2 type names; e.g., INTEGER, VARCHAR).processEscapes
- A boolean specifying whether SQL escapes in the SQL statement are to be processed.
Set processEscapes to… |
To… |
true | Process SQL escapes |
false | Ignore SQL escapes |
Key |
Value |
results | A com.wm.util.Table containing the result set. |
$rowCount | Number of rows in the result set. |
public Values getTables(java.lang.String catalog, java.lang.String schemaPattern, java.lang.String tableNamePattern, java.lang.String[] tableTypes)
getTables
in class DBConnection
catalog
- A String specifying the catalog you want to search.schemaPattern
- A String specifying the schema whose tables you want information about. If the database supports pattern matching on schemas, you may specify a pattern-matching string, where '%' matches one or more characters and a '_' matches one character.tableNamePattern
- A String specifying the table you want information about. If the database supports pattern matching on schemas, you may specify a pattern-matching string, where '%' matches one or more characters and a '_' matches one character.tableTypes
- A String [] specifying the types of tables you want information about (e.g., TABLE, VIEW).public Values getTableInfo(java.lang.String catalog, java.lang.String schemaPattern, java.lang.String tableNamePattern, java.lang.String colNamePattern)
getTableInfo
in class DBConnection
catalog
- A String specifying the catalog that you want to search.schemaPattern
- A String specifying the schema whose tables you want information about. If the database supports pattern matching on schemas, you may specify a pattern-matching string, where '%' matches one or more characters and a '_' matches one character.tableNamePattern
- A String specifying the name of the table for which you want information. If the database supports pattern matching on schemas, you may specify a pattern-matching string, where '%' matches one or more characters and a '_' matches one character.colNamePattern
- A String specifying a column name. If the database supports pattern matching on schemas, you may specify a pattern-matching string, where '%' matches one or more characters and a '_' matches one character.public Values getProcs(java.lang.String catalog, java.lang.String schemaPattern, java.lang.String procNamePattern)
getProcs
in class DBConnection
catalog
- A String specifying the catalog you want to search.schemaPattern
- A String specifying the schema whose procedures you want information about. If the database supports pattern matching on schemas, you may specify a pattern-matching string, where '%' matches one or more characters and a '_' matches one character.procNamePattern
- A String specifying the name of the stored procedure about which you want information. If the database supports pattern matching on schemas, you may specify a pattern-matching string, where '%' matches one or more characters and a '_' matches one character.public Values getProcInfo(java.lang.String catalog, java.lang.String schemaPattern, java.lang.String proc)
getProcInfo
in class DBConnection
catalog
- A String specifying the catalog that you want to search.schemaPattern
- A String specifying the schema whose stored procedures you want information about. If the database supports pattern matching on schemas, you may specify a pattern-matching string, where '%' matches one or more characters and a '_' matches one character.proc
- A String specifying the name of the stored procedure whose information you want to retrieve.public static void toValues(java.sql.ResultSet set, Values results) throws java.sql.SQLException
set
- The Java ResultSet that you want to convert.results
- The Values object into which the entries generated from the Java ResultSet object are put.java.sql.SQLException
public static Values handleSQLException(java.sql.SQLException e, java.lang.String loc)
e
- The SQLException that you want to convert.loc
- A String that you want to use to identify this particular SQLException.