ilog.views.maps.format.oracle
Class IlvSDOConnection

java.lang.Object
  extended by ilog.views.maps.format.oracle.IlvSDOConnection
All Implemented Interfaces:
IlvPersistentObject

public class IlvSDOConnection
extends Object
implements IlvPersistentObject

A persistent class used to save Oracle Connection parameters. An IlvSDOConnection object stores the parameters used to open an Oracle connection. The parameters are the JDBC URL, the user name, and optionally, the password of the connection. You have to call createConnection to create the current JDBC Connection. You should extend this class to use your own connection mechanism. For instance, in order to use Connection Pools, extend this class and override the getConnection method.

Since:
JViews 3.0
See Also:
getConnection()

Constructor Summary
IlvSDOConnection(IlvInputStream stream)
          Reads an IlvSDOConnection from an IlvInputStream.
IlvSDOConnection(String url, String user, String password)
          Initializes an instance of IlvSDOConnection.
 
Method Summary
 boolean createConnection()
          This method opens the Oracle connection using the parameters of the IlvSDOConnection.
 Connection getConnection()
          Returns the encapsulated java.sql.Connection.
static IlvSDOConnectionFactory GetConnectionFactory()
          Returns the installed connection factory.
 String getPassword()
          Returns the current password if isSavingPassword returns true.
 String getUrl()
          Returns the URL of the JDBC connection.
 String getUser()
          Returns the current user.
 boolean isSavingPassword()
          Returns true if the password is saved in an .ivl file.
static void SetConnectionFactory(IlvSDOConnectionFactory factory)
          Installs a connection factory.
 void setPassword(String passwd)
          Sets the current password.
 void setSavingPassword(boolean savePassword)
          Specifies whether the password should be saved in an .ivl file.
 void setUrl(String url)
          Sets the URL for the connection.
 void setUser(String user)
          Sets the current user.
 void write(IlvOutputStream stream)
          Writes the IlvSDOConnection into an IlvOutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvSDOConnection

public IlvSDOConnection(String url,
                        String user,
                        String password)
Initializes an instance of IlvSDOConnection.

Parameters:
url - A database URL of the form jdbc:subprotocol:subname. Examples follow: jdbc:oracle:oci7:@[sid], where [sid] is the server id for the oci7 driver. Or for the thin driver: jdbc:oracle:thin:@[host]:[port]:[sid], where [host] is the hostname of the machine Oracle is running on, [port] is the connection port number and [sid] is the server id.
user - The name of the user of the Oracle session.
password - The password to open the Oracle session. This argument can have a null value.
See Also:
setSavingPassword(boolean)

IlvSDOConnection

public IlvSDOConnection(IlvInputStream stream)
                 throws IlvReadFileException
Reads an IlvSDOConnection from an IlvInputStream.

Throws:
IlvReadFileException
Method Detail

write

public void write(IlvOutputStream stream)
           throws IOException
Writes the IlvSDOConnection into an IlvOutputStream.

Specified by:
write in interface IlvPersistentObject
Parameters:
stream - the output stream
Throws:
IOException - if an error occurred while writing this object.

createConnection

public boolean createConnection()
                         throws SQLException
This method opens the Oracle connection using the parameters of the IlvSDOConnection. This method is called by the connection factories when they have restored the connection parameters.

Returns:
This function returns false if the connection is already connected and returns true if the connection is successfully made.
Throws:
SQLException - if the connection could not be opened.
See Also:
IlvSDOConnectionFactory

isSavingPassword

public boolean isSavingPassword()
Returns true if the password is saved in an .ivl file.


setSavingPassword

public void setSavingPassword(boolean savePassword)
Specifies whether the password should be saved in an .ivl file. By default, the password is not saved.

Parameters:
savePassword - If set to true, the password will be saved with the connection. Otherwise, it is not saved in an .ivl file and the internal value for the password is set to null.

getUrl

public String getUrl()
Returns the URL of the JDBC connection.


getUser

public String getUser()
Returns the current user. If the current sdo connection has been constructed with a null user, a request is sent to the DB in order to define the current user that will be returned by this method.


getPassword

public String getPassword()
Returns the current password if isSavingPassword returns true. Otherwise, it returns a null pointer.


getConnection

public Connection getConnection()
Returns the encapsulated java.sql.Connection. You can extend IlvSDOConnection and override this method to use your own mechanism of connection creation (the connection Pools for instance).


setUrl

public void setUrl(String url)
Sets the URL for the connection.


setUser

public void setUser(String user)
Sets the current user.


setPassword

public void setPassword(String passwd)
Sets the current password.


GetConnectionFactory

public static final IlvSDOConnectionFactory GetConnectionFactory()
Returns the installed connection factory.


SetConnectionFactory

public static final void SetConnectionFactory(IlvSDOConnectionFactory factory)
Installs a connection factory.



Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.