com.sas.rio
Class MVAConnection

com.sas.rio.MVAConnection
All Implemented Interfaces:
java.sql.Connection, java.sql.Wrapper

public class MVAConnection
implements java.sql.Connection

A Connection represents a session with a specific database. Within the context of a Connection, SQL statements are executed and results are returned.

A Connection's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, etc. This information is obtained with the getMetaData method.

Note: By default the Connection automatically commits changes after executing each statement. If auto commit has been disabled, an explicit commit must be done or database changes will not be saved.

See Also:
DriverManager.getConnection(java.lang.String, java.util.Properties), Statement, ResultSet, DatabaseMetaData

Constructor Summary
MVAConnection(com.sas.iom.SAS.IDataService sasDataService, java.util.Properties info)
          Constructs an MVAConnection object.
MVAConnection(com.sas.iom.SAS.IWorkspace sasWorkspace, java.util.Properties info)
          Constructs an MVAConnection object.
MVAConnection(java.lang.String url, java.util.Properties info)
          Constructs an MVAConnection object.
MVAConnection(com.sas.rio.XUtil x, java.util.Properties p)
           
 
Method Summary
 void clearWarnings()
          Clears the warnings.
 void close()
          In some cases, it is desirable to immediately release a Connection's database and JDBC resources instead of waiting for them to be automatically released; the close method provides this immediate release.
 void commit()
          Closes all the open Statement and PreparedStatement objects that are associated with this object.
 java.sql.Statement createStatement()
          Creates a Statement object.
 java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency)
          Same as createStatement() above, but allows the default result set type and result set concurrency type to be overridden.
 java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Creates a Statement object that will generate ResultSet objects with the given type, concurrency, and holdability.
 boolean getAutoCommit()
          SAS software does not support transactions.
 java.lang.String getCatalog()
          Gets the Connection's current catalog name.
 int getHoldability()
          Retrieves the current holdability of ResultSet objects created using this Connection object.
 java.sql.DatabaseMetaData getMetaData()
          A Connection's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, etc.
 int getTransactionIsolation()
          SAS software does not support transactions.
 java.util.Map getTypeMap()
          Gets the type-map object associated with this connection.
 java.sql.SQLWarning getWarnings()
          Gets the warning reported by calls on this Connection.
protected  com.sas.rio.XUtil getXUtil()
           
 boolean isClosed()
          Tests to see if a Connection is closed.
 boolean isReadOnly()
          SAS software does not support read-only connections.
 java.lang.String nativeSQL(java.lang.String sql)
          Returns the input string.
 java.sql.CallableStatement prepareCall(java.lang.String sql)
          Creates a CallableStatement object.
 java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)
          Same as prepareCall() above, but allows the default result set type and result set concurrency type to be overridden.
 java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql)
          Creates a PreparedStatement object.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int autoGeneratedKeys)
          Creates a default PreparedStatement object that has the capability to retrieve auto-generated keys.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int[] columnIndexes)
          Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)
          Same as prepareStatement() above, but allows the default result set type and result set concurrency type to be overridden.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Creates a PreparedStatement object that will generate ResultSet objects with the given type, concurrency, and holdability.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, java.lang.String[] columnNames)
          Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array.
 void releaseSavepoint(java.sql.Savepoint savepoint)
          Removes the given Savepoint object from the current transaction.
 void rollback()
          SAS software does not support transactions.
 void rollback(java.sql.Savepoint savepoint)
          Undoes all changes made after the given Savepoint object was set.
 void setAutoCommit(boolean autoCommit)
          Sets the auto-commit state.
 void setCatalog(java.lang.String catalog)
          A sub-space of this Connection's database may be selected by setting a catalog name.
 void setHoldability(int holdability)
          Changes the holdability of ResultSet objects created using this Connection object to the given holdability.
 void setReadOnly(boolean readOnly)
          SAS software does not support read-only connections.
 java.sql.Savepoint setSavepoint()
          Creates an unnamed savepoint in the current transaction and returns the new Savepoint object that represents it.
 java.sql.Savepoint setSavepoint(java.lang.String name)
          Creates a savepoint with the given name in the current transaction and returns the new Savepoint object that represents it.
 void setTransactionIsolation(int level)
          SAS software does not support transactions.
 void setTypeMap(java.util.Map map)
          Install a type-map object as the default type-map for this connection.
protected  void statementClosed(java.lang.Object statement)
           
 

Constructor Detail

MVAConnection

public MVAConnection(java.lang.String url,
                     java.util.Properties info)
              throws java.sql.SQLException
Constructs an MVAConnection object.

Parameters:
url - initial input url containing host and port information.
info - java.util.Properties object which contains:

userName
MVA server access user name

password
MVA server access password

librefs
a semi-colon delimited list of 'name filepath'.

encryptionPolicy
whether or not JavaBridge should attempt to negotiate with the server over which encryption algorithm to use and what to do if the negotiations fail. Possible values:
none
do not use encryption. This is the default.
optional
attempt to use encryption but, if algorithm negotiation fails, continue with an unencrypted session
required
attempt to use encryption but, if algorithm negotiation fails, fail the connection

encryptionContent
specifies which messages should be encrypted if encryption is used. Possible values:
all
encrypt all messages. This is the default.
authentication
encrypt only messages that contain user name and password information.

encryptionAlgorithms
the list of algorithms you are willing to use in order of preference. Values in the list should be separated by commas and chosen from sasproprietary, rc2, rc4, aes, des, or tripledes. If no value is specified, then one of the server's favorite algorithms will be used.

applyFormats
specifies whether or not column formats are applied when retrieving data. If the value is true, all data is returned as Strings. For any column, the format used is the one defined on the column in the dataset. If "applyFormats" is set to false (the default case) no formatting is applied.

Note that the server's encryption policy is, by default, optional so no special action is needed to prepare an IOM BRIDGE server to use encryption. However, it is possible to set up the server so that encryption is required. Consult IOM BRIDGE server documentation for details.

Throws:
java.sql.SQLException - This exception is thrown if a ShareNetException is detected.

MVAConnection

public MVAConnection(com.sas.iom.SAS.IDataService sasDataService,
                     java.util.Properties info)
              throws java.sql.SQLException
Constructs an MVAConnection object.

Parameters:
sasDataService - IDataService object.
info - java.util.Properties object which contains:
userName
MVA server access user name
password
MVA server access password
librefs
a semi-colon delimited list of 'name filepath'.
Throws:
java.sql.SQLException - This exception is thrown if a ShareNetException is detected.

MVAConnection

public MVAConnection(com.sas.iom.SAS.IWorkspace sasWorkspace,
                     java.util.Properties info)
              throws java.sql.SQLException
Constructs an MVAConnection object.

Parameters:
sasWorkspace - IWorkspace object.
info - java.util.Properties object which contains:
userName
MVA server access user name
password
MVA server access password
librefs
a semi-colon delimited list of 'name filepath'.
Throws:
java.sql.SQLException - This exception is thrown if a ShareNetException is detected.

MVAConnection

public MVAConnection(com.sas.rio.XUtil x,
                     java.util.Properties p)
              throws java.sql.SQLException
Throws:
java.sql.SQLException
Method Detail

createStatement

public java.sql.Statement createStatement()
                                   throws java.sql.SQLException
Creates a Statement object. SQL statements without parameters are normally executed using Statement objects. If the same SQL statement is executed many times, it is more efficient to use a PreparedStatement JDBC 2.0 Result sets created using the returned Statement will have forward-only type, and read-only concurrency, by default.

Specified by:
createStatement in interface java.sql.Connection
Returns:
a new Statement object
Throws:
java.sql.SQLException - This exception is thrown if an MVAStatement object cannot be created.

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                            throws java.sql.SQLException
Creates a PreparedStatement object. A SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. This object can then be used to efficiently execute this statement multiple times. JDBC 2.0 Result sets created using the returned PreparedStatement will have forward-only type, and read-only concurrency, by default.

Specified by:
prepareStatement in interface java.sql.Connection
Parameters:
sql - A SQL statement that may contain one or more '?' IN parameter placeholders.
Returns:
A new PreparedStatement object containing the pre-compiled statement.
Throws:
java.sql.SQLException - This exception is thrown if a PreparedStatement object cannot be created.

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql)
                                       throws java.sql.SQLException
Creates a CallableStatement object. JDBC 2.0 Result sets created using the returned CallableStatement will have forward-only type, and read-only concurrency, by default.

Specified by:
prepareCall in interface java.sql.Connection
Parameters:
sql - A SQL statement that may contain one or more '?' parameter placeholders. Typically this statement is a JDBC function call escape string.
Returns:
A new CallableStatement object containing the pre-compiled SQL statement
Throws:
java.sql.SQLException - This exception is required by the interface but it is never thrown.

nativeSQL

public java.lang.String nativeSQL(java.lang.String sql)
                           throws java.sql.SQLException
Returns the input string. The SQL is not optimized.

Specified by:
nativeSQL in interface java.sql.Connection
Parameters:
sql - An input SQL string for optimization.
Returns:
An input string.
Throws:
java.sql.SQLException - This exception is required by the interface, but it is never thrown.

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws java.sql.SQLException
Sets the auto-commit state.

Specified by:
setAutoCommit in interface java.sql.Connection
Parameters:
autoCommit - This value must be True. SAS software does not support transactions.
Throws:
java.sql.SQLException - This exception is thrown if the value for autoCommit is False.

getAutoCommit

public boolean getAutoCommit()
                      throws java.sql.SQLException
SAS software does not support transactions. All statements are committed individually. The current auto-commit state is always True.

Specified by:
getAutoCommit in interface java.sql.Connection
Returns:
True.
Throws:
java.sql.SQLException - This exception is required by the interface, but it is never thrown.

commit

public void commit()
            throws java.sql.SQLException
Closes all the open Statement and PreparedStatement objects that are associated with this object.

Specified by:
commit in interface java.sql.Connection
Throws:
java.sql.SQLException - This exception is thrown if an exception occurred while outstanding statements were being closed.

rollback

public void rollback()
              throws java.sql.SQLException
SAS software does not support transactions. This method is not supported.

Specified by:
rollback in interface java.sql.Connection
Throws:
java.sql.SQLException - This exception is always thrown.

close

public void close()
           throws java.sql.SQLException
In some cases, it is desirable to immediately release a Connection's database and JDBC resources instead of waiting for them to be automatically released; the close method provides this immediate release.

Note: A Connection is automatically closed when it is garbage collected. Certain fatal errors also result in a closed Connection.

Specified by:
close in interface java.sql.Connection
Throws:
java.sql.SQLException - This exception is thrown if an error condition is detected.

isClosed

public boolean isClosed()
                 throws java.sql.SQLException
Tests to see if a Connection is closed.

Specified by:
isClosed in interface java.sql.Connection
Returns:
true if the connection is closed; false if it's still open
Throws:
java.sql.SQLException - This exception is required by the interface but it is never thrown.

getMetaData

public java.sql.DatabaseMetaData getMetaData()
                                      throws java.sql.SQLException
A Connection's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, etc. This information is made available through a DatabaseMetaData object.

Specified by:
getMetaData in interface java.sql.Connection
Returns:
a DatabaseMetaData object for this Connection
Throws:
java.sql.SQLException - This exception is thrown if an DatabaseMetaData object cannot be created.

setReadOnly

public void setReadOnly(boolean readOnly)
                 throws java.sql.SQLException
SAS software does not support read-only connections. The input value is ignored.

Specified by:
setReadOnly in interface java.sql.Connection
Parameters:
readOnly - This parameter is ignored.
Throws:
java.sql.SQLException - This exception is required by the interface, but it is never thrown.

isReadOnly

public boolean isReadOnly()
                   throws java.sql.SQLException
SAS software does not support read-only connections. The readOnly value is always False.

Specified by:
isReadOnly in interface java.sql.Connection
Returns:
False.
Throws:
java.sql.SQLException - This exception is required by the interface, but it is never thrown.

setCatalog

public void setCatalog(java.lang.String catalog)
                throws java.sql.SQLException
A sub-space of this Connection's database may be selected by setting a catalog name. If the driver does not support catalogs it will silently ignore this request. NOTE: SAS software does not support catalogs and so the catalog string will be silently ignored.

Specified by:
setCatalog in interface java.sql.Connection
Throws:
java.sql.SQLException - This exception is required by the interface but it is never thrown.

getCatalog

public java.lang.String getCatalog()
                            throws java.sql.SQLException
Gets the Connection's current catalog name.

Specified by:
getCatalog in interface java.sql.Connection
Returns:
NULL. SAS software does not support catalogs.
Throws:
java.sql.SQLException - if a database-access error occurs.

setTransactionIsolation

public void setTransactionIsolation(int level)
                             throws java.sql.SQLException
SAS software does not support transactions. The only valid input value is java.sql.Connection.TRANSACTION_NONE.

Specified by:
setTransactionIsolation in interface java.sql.Connection
Parameters:
level - The transaction level.
Throws:
java.sql.SQLException - This exception is thrown if the value of level is not valid.

getTransactionIsolation

public int getTransactionIsolation()
                            throws java.sql.SQLException
SAS software does not support transactions.

Specified by:
getTransactionIsolation in interface java.sql.Connection
Returns:
java.sql.Connection.TRANSACTION_NONE.
Throws:
java.sql.SQLException - This exception is required by the interface, but it is never thrown.

getWarnings

public java.sql.SQLWarning getWarnings()
                                throws java.sql.SQLException
Gets the warning reported by calls on this Connection.

Note: Subsequent warnings will be chained to this SQLWarning.

Specified by:
getWarnings in interface java.sql.Connection
Returns:
The SQLWarning.
Throws:
java.sql.SQLException - This exception is required by the interface but it is never thrown.

clearWarnings

public void clearWarnings()
                   throws java.sql.SQLException
Clears the warnings.

Specified by:
clearWarnings in interface java.sql.Connection
Throws:
java.sql.SQLException - This exception is required by the interface but it is never thrown.

createStatement

public java.sql.Statement createStatement(int resultSetType,
                                          int resultSetConcurrency)
                                   throws java.sql.SQLException
Same as createStatement() above, but allows the default result set type and result set concurrency type to be overridden. If an invalid type or concurrency is passed, the values are defaulted to TYPE_FORWARD_ONLY and CONCUR_READ_ONLY. If an invalid scrolling type or concurrency is requested, then a valid scrolling type (or concurrency) is substituted, and a warning is generated. JDBC 2.0

Specified by:
createStatement in interface java.sql.Connection
Parameters:
resultSetType - a result set type, see ResultSet.TYPE_XXX
resultSetConcurrency - a concurrency type, see ResultSet.CONCUR_XXX
Returns:
a new Statement object
Throws:
java.sql.SQLException - This exception is thrown if a Statement object cannot be created.

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int resultSetType,
                                                   int resultSetConcurrency)
                                            throws java.sql.SQLException
Same as prepareStatement() above, but allows the default result set type and result set concurrency type to be overridden. If an invalid type or concurrency is passed, the values are defaulted to TYPE_FORWARD_ONLY and CONCUR_READ_ONLY. If an invalid scroll type or concurrency is requested, then the next closest scrolling/concurrency is substituted, and a warning is generated. JDBC 2.0

Specified by:
prepareStatement in interface java.sql.Connection
Parameters:
resultSetType - a result set type, see ResultSet.TYPE_XXX
resultSetConcurrency - a concurrency type, see ResultSet.CONCUR_XXX
Returns:
a new PreparedStatement object containing the pre-compiled SQL statement
Throws:
java.sql.SQLException - This exception is thrown if a PreparedStatement object cannot be created.

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql,
                                              int resultSetType,
                                              int resultSetConcurrency)
                                       throws java.sql.SQLException
Same as prepareCall() above, but allows the default result set type and result set concurrency type to be overridden. If an invalid type or concurrency is passed, the values are defaulted to TYPE_FORWARD_ONLY and CONCUR_READ_ONLY. If an invalid scroll type/concurrency is requested, the next closest scroll type/concurrency is substituted, and a warning is generated. JDBC 2.0

Specified by:
prepareCall in interface java.sql.Connection
Parameters:
resultSetType - a result set type, see ResultSet.TYPE_XXX
resultSetConcurrency - a concurrency type, see ResultSet.CONCUR_XXX
Returns:
a new CallableStatement object containing the pre-compiled SQL statement
Throws:
java.sql.SQLException - This exception is thrown if a CallableStatement object cannot be created.

getTypeMap

public java.util.Map getTypeMap()
                         throws java.sql.SQLException
Gets the type-map object associated with this connection.

By default, the map returned is empty. Method not supported.

JDBC 2.0

Specified by:
getTypeMap in interface java.sql.Connection
Throws:
java.sql.SQLException - This exception is always thrown as SAS software does not support user defined types.

setTypeMap

public void setTypeMap(java.util.Map map)
                throws java.sql.SQLException
Install a type-map object as the default type-map for this connection. Method not supported. JDBC 2.0

Specified by:
setTypeMap in interface java.sql.Connection
Throws:
java.sql.SQLException - This exception is always thrown as SAS software does not support user defined types.

statementClosed

protected void statementClosed(java.lang.Object statement)

getXUtil

protected com.sas.rio.XUtil getXUtil()

createStatement

public java.sql.Statement createStatement(int resultSetType,
                                          int resultSetConcurrency,
                                          int resultSetHoldability)
                                   throws java.sql.SQLException
Creates a Statement object that will generate ResultSet objects with the given type, concurrency, and holdability. Empty method implementation for JDK1.4 compliance.

Specified by:
createStatement in interface java.sql.Connection
Throws:
java.sql.SQLException - This exception is always thrown to indicate the method is not implemented.

getHoldability

public int getHoldability()
                   throws java.sql.SQLException
Retrieves the current holdability of ResultSet objects created using this Connection object. Empty method implementation for JDK1.4 compliance.

Specified by:
getHoldability in interface java.sql.Connection
Throws:
java.sql.SQLException - This exception is always thrown to indicate the method is not implemented.

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql,
                                              int resultSetType,
                                              int resultSetConcurrency,
                                              int resultSetHoldability)
                                       throws java.sql.SQLException
Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency. Empty method implementation for JDK1.4 compliance.

Specified by:
prepareCall in interface java.sql.Connection
Throws:
java.sql.SQLException - This exception is always thrown to indicate the method is not implemented.

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int autoGeneratedKeys)
                                            throws java.sql.SQLException
Creates a default PreparedStatement object that has the capability to retrieve auto-generated keys. Empty method implementation for JDK1.4 compliance.

Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException - This exception is always thrown to indicate the method is not implemented.

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int[] columnIndexes)
                                            throws java.sql.SQLException
Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. Empty method implementation for JDK1.4 compliance.

Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException - This exception is always thrown to indicate the method is not implemented.

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int resultSetType,
                                                   int resultSetConcurrency,
                                                   int resultSetHoldability)
                                            throws java.sql.SQLException
Creates a PreparedStatement object that will generate ResultSet objects with the given type, concurrency, and holdability. Empty method implementation for JDK1.4 compliance.

Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException - This exception is always thrown to indicate the method is not implemented.

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   java.lang.String[] columnNames)
                                            throws java.sql.SQLException
Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. Empty method implementation for JDK1.4 compliance.

Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException - This exception is always thrown to indicate the method is not implemented.

releaseSavepoint

public void releaseSavepoint(java.sql.Savepoint savepoint)
                      throws java.sql.SQLException
Removes the given Savepoint object from the current transaction. Empty method implementation for JDK1.4 compliance.

Specified by:
releaseSavepoint in interface java.sql.Connection
Throws:
java.sql.SQLException - This exception is always thrown to indicate the method is not implemented.

rollback

public void rollback(java.sql.Savepoint savepoint)
              throws java.sql.SQLException
Undoes all changes made after the given Savepoint object was set. Empty method implementation for JDK1.4 compliance.

Specified by:
rollback in interface java.sql.Connection
Throws:
java.sql.SQLException - This exception is always thrown to indicate the method is not implemented.

setHoldability

public void setHoldability(int holdability)
                    throws java.sql.SQLException
Changes the holdability of ResultSet objects created using this Connection object to the given holdability. Empty method implementation for JDK1.4 compliance.

Specified by:
setHoldability in interface java.sql.Connection
Throws:
java.sql.SQLException - This exception is always thrown to indicate the method is not implemented.

setSavepoint

public java.sql.Savepoint setSavepoint()
                                throws java.sql.SQLException
Creates an unnamed savepoint in the current transaction and returns the new Savepoint object that represents it. Empty method implementation for JDK1.4 compliance.

Specified by:
setSavepoint in interface java.sql.Connection
Throws:
java.sql.SQLException - This exception is always thrown to indicate the method is not implemented.

setSavepoint

public java.sql.Savepoint setSavepoint(java.lang.String name)
                                throws java.sql.SQLException
Creates a savepoint with the given name in the current transaction and returns the new Savepoint object that represents it. Empty method implementation for JDK1.4 compliance.

Specified by:
setSavepoint in interface java.sql.Connection
Throws:
java.sql.SQLException - This exception is always thrown to indicate the method is not implemented.



Copyright © 2009 SAS Institute Inc. All Rights Reserved.