com.sas.net.sharenet
Class ShareNetConnection

com.sas.net.sharenet.ShareNetConnection
All Implemented Interfaces:
java.sql.Connection, java.sql.Wrapper

public class ShareNetConnection
implements java.sql.Connection

This class establishes a session with a SAS/SHARE server.


Field Summary
protected  com.sas.net.sharenet.Wqecon con
           
protected  com.sas.net.sharenet.Defdestroy defdes
           
protected  com.sas.net.sharenet.Tcpmsg msg
           
protected  int resultSetConcurrency
           
protected  int resultSetType
           
protected  int sharenetType
           
protected  java.lang.String version_msg
           
 java.sql.SQLWarning warnings
           
protected  com.sas.net.sharenet.Xherscon xher1
           
 
Constructor Summary
ShareNetConnection(java.lang.String host, int port, java.util.Properties info, com.sas.net.sharenet.Wqecon con)
          Constructs a ShareNetConnection object.
ShareNetConnection(java.lang.String url, java.util.Properties info)
          Constructs a ShareNetConnection object.
 
Method Summary
 void clearWarnings()
          Removes all warnings that are associated with this object.
 void close()
          Closes all the ShareNetStatement and ShareNetPreparedStatement objects that are associated with this object and closes the connection to the server.
 void commit()
          Closes all the open Statement and PreparedStatement objects that are associated with this object.
protected  void connect(java.lang.String myhost, int port)
          Connect to the server.
 java.sql.Statement createStatement()
          Creates a ShareNetStatement object.
 java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency)
          JDBC 2.0 Creates a Statement object by allowing 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.
protected  void deleteStatement(java.lang.Object statement)
          Protected method which deletes statements associated with this object.
protected  int execute(java.lang.String command)
          Execute a command on the remote server.
protected  void finalize()
          Protected method which cleans up state associated with this object.
protected static java.lang.String formatMsg(int acc, com.sas.net.sharenet.Ans1 ans1, com.sas.net.sharenet.Rcmsg rcmsg)
          Format the response from the server.
 boolean getAutoCommit()
          SAS software does not support transactions.
 java.lang.String getCatalog()
          SAS software does not support SQL catalogs.
 int getHoldability()
          Retrieves the current holdability of ResultSet objects created using this Connection object.
 java.sql.DatabaseMetaData getMetaData()
          Creates a ShareNetDatabaseMetaData object.
protected  boolean getRemarks()
          Protected method
 int getTransactionIsolation()
          SAS software does not support transactions.
 java.util.Map getTypeMap()
          JDBC 2.0 Gets the type-map object associated with this connection as a java.util.Map object.
protected  java.lang.String getUrl()
          Protected method
protected  java.lang.String getUser()
          Protected method
 java.sql.SQLWarning getWarnings()
          Returns the warnings associated with this object.
 boolean isClosed()
          Indicates whether the connection to the server is closed.
protected  boolean isConnected()
          Gets the state of the connection.
 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 ShareNetCallableStatement object.
 java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)
          JDBC 2.0 Creates a CallableStatement object by allowing 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, concurrency, and holdability.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql)
          Creates a ShareNetPreparedStatement 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)
          JDBC 2.0 Creates a PreparedStatement object by allowing 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)
          SAS software does not support SQL catalogs.
 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)
          JDBC 2.0 Sets a type-map object as the default type-map for this connection.
 

Field Detail

warnings

public java.sql.SQLWarning warnings

con

protected com.sas.net.sharenet.Wqecon con

xher1

protected com.sas.net.sharenet.Xherscon xher1

defdes

protected com.sas.net.sharenet.Defdestroy defdes

msg

protected com.sas.net.sharenet.Tcpmsg msg

sharenetType

protected int sharenetType

version_msg

protected java.lang.String version_msg

resultSetType

protected int resultSetType

resultSetConcurrency

protected int resultSetConcurrency
Constructor Detail

ShareNetConnection

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

Parameters:
url - initial input url
info - java.util.Properties object which contains properties needed to obtain a connection.
Throws:
java.sql.SQLException - This exception is thrown if a ShareNetException is detected.
See Also:
ShareNetDriver.connect

ShareNetConnection

public ShareNetConnection(java.lang.String host,
                          int port,
                          java.util.Properties info,
                          com.sas.net.sharenet.Wqecon con)
                   throws java.sql.SQLException
Constructs a ShareNetConnection object.

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

createStatement

public java.sql.Statement createStatement()
                                   throws java.sql.SQLException
Creates a ShareNetStatement object.

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

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                            throws java.sql.SQLException
Creates a ShareNetPreparedStatement object.

Specified by:
prepareStatement in interface java.sql.Connection
Parameters:
sql - An input SQL string.
Returns:
A new ShareNetPreparedStatement object.
Throws:
java.sql.SQLException - This exception is thrown if a ShareNetPreparedStatement cannot be created.

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql)
                                       throws java.sql.SQLException
Creates a ShareNetCallableStatement object.

Specified by:
prepareCall in interface java.sql.Connection
Parameters:
sql - An input SQL string.
Returns:
A new ShareNetCallableStatement object.
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
Closes all the ShareNetStatement and ShareNetPreparedStatement objects that are associated with this object and closes the connection to the server.

Specified by:
close in interface java.sql.Connection
Throws:
java.sql.SQLException - This exception is thrown if a ShareNetException is detected.

isClosed

public boolean isClosed()
                 throws java.sql.SQLException
Indicates whether the connection to the server is closed.

Specified by:
isClosed in interface java.sql.Connection
Returns:
A Boolean that indicates whether the connection to the server is open (False) or closed (True).
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
Creates a ShareNetDatabaseMetaData object. This class will only create DatabaseMetaData objects for connections to SQLVIEW databases. DatabaseMetaData objects will not be created for other databases such as Oracle databases.

Specified by:
getMetaData in interface java.sql.Connection
Returns:
A ShareNetDatabaseMetaData object.
Throws:
java.sql.SQLException - This exception is thrown if a ShareNetDatabaseMetaData 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
SAS software does not support SQL catalogs. The input parameter is ignored.

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

getCatalog

public final java.lang.String getCatalog()
                                  throws java.sql.SQLException
SAS software does not support SQL catalogs. This method always returns a NULL.

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

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
Returns the warnings associated with this object.

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

clearWarnings

public void clearWarnings()
                   throws java.sql.SQLException
Removes all warnings that are associated with this object.

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
JDBC 2.0 Creates a Statement object by allowing the default result set type and result set concurrency type to be overridden. Currently, you cannot override the default result set types and concurrency types. We support only TYPE_FORWARD_ONLY result type and CONCUR_READ_ONLY result set concurrency type.

Specified by:
createStatement in interface java.sql.Connection
Parameters:
resultSetType - The result set type TYPE_FORWARD_ONLY.
resultSetConcurrency - The concurrency type CONCUR_READ_ONLY.
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
JDBC 2.0 Creates a PreparedStatement object by allowing the default result set type and result set concurrency type to be overridden. Currently, you cannot override the default result set types and concurrency types. We support only TYPE_FORWARD_ONLY result type and CONCUR_READ_ONLY result set concurrency type.

Specified by:
prepareStatement in interface java.sql.Connection
Parameters:
sql - The SQL statement String.
resultSetType - The result set type TYPE_FORWARD_ONLY.
resultSetConcurrency - The concurrency type CONCUR_READ_ONLY.
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
JDBC 2.0 Creates a CallableStatement object by allowing the default result set type and result set concurrency type to be overridden. Currently, you cannot override the default result set types and concurrency types. We support only TYPE_FORWARD_ONLY result type and CONCUR_READ_ONLY result set concurrency type.

Specified by:
prepareCall in interface java.sql.Connection
Parameters:
sql - The SQL statement String.
resultSetType - The result set type TYPE_FORWARD_ONLY.
resultSetConcurrency - The concurrency type CONCUR_READ_ONLY.
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
JDBC 2.0 Gets the type-map object associated with this connection as a java.util.Map object. By default, the map returned is empty. This method is not yet supported.

Specified by:
getTypeMap in interface java.sql.Connection
Returns:
The type-map object associated with this connection.
Throws:
java.sql.SQLException - This exception is always thrown.

setTypeMap

public void setTypeMap(java.util.Map map)
                throws java.sql.SQLException
JDBC 2.0 Sets a type-map object as the default type-map for this connection. This method is not yet supported.

Specified by:
setTypeMap in interface java.sql.Connection
Parameters:
map - A type-map object to be associated with this connection.
Throws:
java.sql.SQLException - This exception is always thrown.

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. This method is not implemented.

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

getHoldability

public int getHoldability()
                   throws java.sql.SQLException
Retrieves the current holdability of ResultSet objects created using this Connection object. This method is not implemented.

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

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. This method is not implemented.

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

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. This method is not implemented.

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

rollback

public void rollback(java.sql.Savepoint savepoint)
              throws java.sql.SQLException
Undoes all changes made after the given Savepoint object was set. This method is not implemented.

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

releaseSavepoint

public void releaseSavepoint(java.sql.Savepoint savepoint)
                      throws java.sql.SQLException
Removes the given Savepoint object from the current transaction. This method is not implemented.

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

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. This method is not implemented.

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

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. This method is not implemented.

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

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, concurrency, and holdability. This method is not implemented.

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

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. This method is not implemented.

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

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. This method is not implemented.

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

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. This method is not implemented.

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

deleteStatement

protected void deleteStatement(java.lang.Object statement)
Protected method which deletes statements associated with this object. Called by the statement's close method.

Parameters:
statement - statement object to be removed from the statementList

getUser

protected java.lang.String getUser()
Protected method

Returns:
String username associated with this object

getUrl

protected java.lang.String getUrl()
Protected method

Returns:
String url associated with this object

getRemarks

protected boolean getRemarks()
Protected method

Returns:
boolean remarks

finalize

protected void finalize()
                 throws java.lang.Throwable
Protected method which cleans up state associated with this object.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Exception - Throwable is required, but it is never thrown.
java.lang.Throwable

connect

protected void connect(java.lang.String myhost,
                       int port)
                throws ShareNetException
Connect to the server.

Parameters:
host - host machine name
port - TCP/IP port number
Throws:
ShareNetException - if an IOException is detected

execute

protected int execute(java.lang.String command)
               throws ShareNetException
Execute a command on the remote server. Typically, this is used to define new data sets.

Parameters:
command - command
Returns:
count number of records updated
Throws:
ShareNetException - if an IOException is detected

isConnected

protected boolean isConnected()
Gets the state of the connection.

Returns:
connected A boolean value indicating the state of the connection.

formatMsg

protected static java.lang.String formatMsg(int acc,
                                            com.sas.net.sharenet.Ans1 ans1,
                                            com.sas.net.sharenet.Rcmsg rcmsg)
                                     throws ShareNetException
Format the response from the server.

Parameters:
acc - response code from server
ans1 - answer segment one from the server
rcmsg - response message from the server
Throws:
ShareNetException - if an IOException is detected



Copyright © 2009 SAS Institute Inc. All Rights Reserved.