|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--oracle.sqlj.runtime.Oracle
This class provides concise methods for establishing and installing SQLJ database connections. Two basic methods are provided: "getConnection" and "connect". The "getConnection" method is used to create a new database connection and return a handle to it in the form of connection context instance. The "connect" method is similar to the "getConnection" method in that it creates a new database connection. However, "connect" additionally installs the new connection as the static default context. Moreover, "connect" does not create a new connection if a static default context was previously installed.
The "getConnection" method is used when multiple or explicitly passed connection contexts are required, whereas the "connect" method is used when a single, implictly shared connection context is acceptable.
Both "getConnection" and "connect" exist with a number of different overloaded signatures to meet various connection requirements. The overloadings correspond to the overloadings of the DefaultContext constructors. Additional overloadings are provided which allow connections to be established using property file settings.
A number of method overloadings differ only in the extance or absence of an auto-commit argument. When auto-commit is not explicitly passed, new connections are created with auto-commit turned off. Note that this is different behavior from standard JDBC drivers, which create connections with auto-commit turned on by default.
This class can be used to establish a database connection using the Oracle JDBC drivers. Explicit registration of the Oracle JDBC driver is not required, as registration is performed implicitly when needed. This class can also be used to connect using non-Oracle drivers. In such cases, registration of the required drivers must be performed explicitly by the client.
DefaultContext
Field Summary |
Type | Field |
---|---|
static java.lang.String |
PASSWORD_KEY
The name of the password key within a properties file: "sqlj.password" |
static java.lang.String |
SQLJ_PROPERTIES
The name of the default properties file: "sqlj.properties" |
static java.lang.String |
URL_KEY
The name of the url key within a properties file: "sqlj.url" |
static java.lang.String |
USER_KEY
The name of the user key within a properties file: "sqlj.user" |
Constructor Summary |
Oracle()
|
Method Summary |
Type | Method |
---|---|
static void |
close()
Releases all resources used in maintaining database state on the default context: closes any open connected profiles, and closes the underlying jdbc connection. |
static void |
close(boolean closeConnection)
Releases all resources used in maintaining database state on the default context: closes any open connected profiles, and optionally closes the underlying jdbc connection - since the underlying JDBC connection managed by this context may be shared between mutliple context objects, it is not always desireable to close the underlying JDBC Connection when close is called. |
static DefaultContext |
connect(java.lang.Class loadCtx,
java.lang.String propName)
Creates and installs a new connection context instance as the static default context if one did not previously exist. |
static DefaultContext |
connect(java.lang.Class loadCtx,
java.lang.String propName,
boolean autoCommit)
Creates and installs a new connection context instance as the static default context if one did not previously exist. |
static DefaultContext |
connect(java.lang.Class loadCtx,
java.lang.String propName,
java.lang.String user,
java.lang.String password)
Creates and installs a new connection context instance as the static default context if one did not previously exist. |
static DefaultContext |
connect(java.lang.Class loadCtx,
java.lang.String propName,
java.lang.String user,
java.lang.String password,
boolean autoCommit)
Creates and installs a new connection context instance as the static default context if one did not previously exist. |
static DefaultContext |
connect(java.sql.Connection conn)
Creates and installs a new connection context instance as the static default context if one did not previously exist. |
static DefaultContext |
connect(ConnectionContext other)
Creates and installs a new connection context instance as the static default context if one did not previously exist. |
static DefaultContext |
connect(java.lang.String url)
Creates and installs a new connection context instance as the static default context if one did not previously exist. |
static DefaultContext |
connect(java.lang.String url,
boolean autoCommit)
Creates and installs a new connection context instance as the static default context if one did not previously exist. |
static DefaultContext |
connect(java.lang.String url,
java.util.Properties info)
Creates and installs a new connection context instance as the static default context if one did not previously exist. |
static DefaultContext |
connect(java.lang.String url,
java.util.Properties info,
boolean autoCommit)
Creates and installs a new connection context instance as the static default context if one did not previously exist. |
static DefaultContext |
connect(java.lang.String url,
java.lang.String user,
java.lang.String password)
Creates and installs a new connection context instance as the static default context if one did not previously exist. |
static DefaultContext |
connect(java.lang.String url,
java.lang.String user,
java.lang.String password,
boolean autoCommit)
Creates and installs a new connection context instance as the static default context if one did not previously exist. |
static DefaultContext |
getConnection(java.lang.Class loadCtx,
java.lang.String propName)
Returns a new default context instance whose underlying connection is created based on the "sqlj.url", "sqlj.user", and "sqlj.password" entries of a property file. |
static DefaultContext |
getConnection(java.lang.Class loadCtx,
java.lang.String propName,
boolean autoCommit)
Returns a new default context instance whose underlying connection is created based on the "sqlj.url", "sqlj.user", and "sqlj.password" entries of a property file and the passed auto-commit mode. |
static DefaultContext |
getConnection(java.lang.Class loadCtx,
java.lang.String propName,
java.lang.String user,
java.lang.String password)
Returns a new default context instance whose underlying connection is created based on the "sqlj.url" entry of a property file, and the passed user and password. |
static DefaultContext |
getConnection(java.lang.Class loadCtx,
java.lang.String propName,
java.lang.String user,
java.lang.String password,
boolean autoCommit)
Returns a new default context instance whose underlying connection is created based on the "sqlj.url" entry of a property file, and the passed user, password and auto-commit mode. |
static DefaultContext |
getConnection(java.sql.Connection conn)
Returns a new default context instance which uses the passed connection as its underlying connection. |
static DefaultContext |
getConnection(ConnectionContext other)
Returns a new default context instance which uses the same underlying connection as the passed connection context instance. |
static DefaultContext |
getConnection(java.lang.String url)
Returns a new default context instance whose underlying connection is created based on the passed url. |
static DefaultContext |
getConnection(java.lang.String url,
boolean autoCommit)
Returns a new default context instance whose underlying connection is created based on the passed url and auto-commit mode. |
static DefaultContext |
getConnection(java.lang.String url,
java.util.Properties info)
Returns a new default context instance whose underlying connection is created based on the passed url and properties information. |
static DefaultContext |
getConnection(java.lang.String url,
java.util.Properties info,
boolean autoCommit)
Returns a new default context instance whose underlying connection is created based on the passed url, properties information, and auto-commit mode. |
static DefaultContext |
getConnection(java.lang.String url,
java.lang.String user,
java.lang.String password)
Returns a new default context instance whose underlying connection is created based on the passed url, user, and password. |
static DefaultContext |
getConnection(java.lang.String url,
java.lang.String user,
java.lang.String password,
boolean autoCommit)
Returns a new default context instance whose underlying connection is created based on the passed url, user, password and auto-commit mode. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final java.lang.String SQLJ_PROPERTIES
public static final java.lang.String USER_KEY
public static final java.lang.String PASSWORD_KEY
public static final java.lang.String URL_KEY
Constructor Detail |
public Oracle()
Method Detail |
public static DefaultContext connect(java.sql.Connection conn) throws java.sql.SQLException
Most clients will ignore the return value of this method.
conn
- the underlying connection for the context instance.DefaultContext.setDefaultContext(sqlj.runtime.ref.DefaultContext)
,
DefaultContext.getDefaultContext()
,
getConnection(java.sql.Connection)
public static DefaultContext connect(java.lang.String url, java.lang.String user, java.lang.String password, boolean autoCommit) throws java.sql.SQLException
Most clients will ignore the return value of this method.
url
- the database urluser
- the usernamepassword
- the user passwordautoCommit
- true if the connection should be created in
auto-commit mode, false otherwiseDefaultContext.setDefaultContext(sqlj.runtime.ref.DefaultContext)
,
DefaultContext.getDefaultContext()
,
getConnection(String, String, String, boolean)
public static DefaultContext connect(java.lang.String url, java.lang.String user, java.lang.String password) throws java.sql.SQLException
Most clients will ignore the return value of this method.
url
- the database urluser
- the usernamepassword
- the user passwordDefaultContext.setDefaultContext(sqlj.runtime.ref.DefaultContext)
,
DefaultContext.getDefaultContext()
,
getConnection(String,String,String)
public static DefaultContext connect(java.lang.String url, java.util.Properties info, boolean autoCommit) throws java.sql.SQLException
Most clients will ignore the return value of this method.
url
- the database urlinfo
- a list of properties for the connectionautoCommit
- true if the connection should be created in
auto-commit mode, false otherwiseDefaultContext.setDefaultContext(sqlj.runtime.ref.DefaultContext)
,
DefaultContext.getDefaultContext()
,
getConnection(String, java.util.Properties, boolean)
public static DefaultContext connect(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
Most clients will ignore the return value of this method.
url
- the database urlinfo
- a list of properties for the connectionDefaultContext.setDefaultContext(sqlj.runtime.ref.DefaultContext)
,
DefaultContext.getDefaultContext()
,
getConnection(String,java.util.Properties)
public static DefaultContext connect(java.lang.String url, boolean autoCommit) throws java.sql.SQLException
Most clients will ignore the return value of this method.
url
- the database urlautoCommit
- true if the connection should be created in
auto-commit mode, false otherwiseDefaultContext.setDefaultContext(sqlj.runtime.ref.DefaultContext)
,
DefaultContext.getDefaultContext()
,
getConnection(String, boolean)
public static DefaultContext connect(java.lang.String url) throws java.sql.SQLException
Most clients will ignore the return value of this method.
url
- the database urlDefaultContext.setDefaultContext(sqlj.runtime.ref.DefaultContext)
,
DefaultContext.getDefaultContext()
,
getConnection(String)
public static DefaultContext connect(ConnectionContext other) throws java.sql.SQLException
Most clients will ignore the return value of this method.
other
- the context with which to share an underlying connection.DefaultContext.setDefaultContext(sqlj.runtime.ref.DefaultContext)
,
DefaultContext.getDefaultContext()
,
getConnection(sqlj.runtime.ConnectionContext)
public static DefaultContext connect(java.lang.Class loadCtx, java.lang.String propName, boolean autoCommit) throws java.sql.SQLException
Most clients will ignore the return value of this method.
loadCtx
- the class used to load the properties filepropName
- the name of the properties file to loadautoCommit
- true if the connection should be created in
auto-commit mode, false otherwiseDefaultContext.setDefaultContext(sqlj.runtime.ref.DefaultContext)
,
DefaultContext.getDefaultContext()
,
getConnection(Class, String, boolean)
public static DefaultContext connect(java.lang.Class loadCtx, java.lang.String propName) throws java.sql.SQLException
Most clients will ignore the return value of this method.
loadCtx
- the class used to load the properties filepropName
- the name of the properties file to loadDefaultContext.setDefaultContext(sqlj.runtime.ref.DefaultContext)
,
DefaultContext.getDefaultContext()
,
getConnection(Class, String)
public static DefaultContext connect(java.lang.Class loadCtx, java.lang.String propName, java.lang.String user, java.lang.String password, boolean autoCommit) throws java.sql.SQLException
Most clients will ignore the return value of this method.
loadCtx
- the class used to load the properties filepropName
- the name of the properties file to loaduser
- the usernamepassword
- the user passwordautoCommit
- true if the connection should be created in
auto-commit mode, false otherwiseDefaultContext.setDefaultContext(sqlj.runtime.ref.DefaultContext)
,
DefaultContext.getDefaultContext()
,
getConnection(Class, String, String, String, boolean)
public static DefaultContext connect(java.lang.Class loadCtx, java.lang.String propName, java.lang.String user, java.lang.String password) throws java.sql.SQLException
Most clients will ignore the return value of this method.
loadCtx
- the class used to load the properties filepropName
- the name of the properties file to loaduser
- the usernamepassword
- the user passwordDefaultContext.setDefaultContext(sqlj.runtime.ref.DefaultContext)
,
DefaultContext.getDefaultContext()
,
getConnection(Class, String, String, String)
public static void close() throws java.sql.SQLException
Oracle.close(CLOSE_CONNECTION)
.
The default connection context is also set to null, permitting a
subsequent Oracle.connect()
call to succeed.
ConnectionContextImpl.close()
,
close(boolean)
public static void close(boolean closeConnection) throws java.sql.SQLException
Oracle.connect()
call to succeed.
closeConnection
- specify CLOSE_CONNECTION if the underlying JDBC
connection is to be closed and KEEP_CONNECTION if it is to
be kept open.ConnectionContext.CLOSE_CONNECTION
,
ConnectionContext.KEEP_CONNECTION
,
ConnectionContextImpl.close(boolean)
,
close()
public static DefaultContext getConnection(java.sql.Connection conn) throws java.sql.SQLException
Notes:
conn
- the underlying connection for the context instance.public static DefaultContext getConnection(java.lang.String url, java.lang.String user, java.lang.String password, boolean autoCommit) throws java.sql.SQLException
Notes:
url
- the database urluser
- the usernamepassword
- the user passwordautoCommit
- true if the connection should be created in
auto-commit mode, false otherwisepublic static DefaultContext getConnection(java.lang.String url, java.lang.String user, java.lang.String password) throws java.sql.SQLException
Notes:
url
- the database urluser
- the usernamepassword
- the user passwordgetConnection(String,String,String,boolean)
public static DefaultContext getConnection(java.lang.String url, java.util.Properties info, boolean autoCommit) throws java.sql.SQLException
Notes:
url
- the database urlinfo
- a list of properties for the connectionautoCommit
- true if the connection should be created in
auto-commit mode, false otherwisepublic static DefaultContext getConnection(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
Notes:
url
- the database urlinfo
- a list of properties for the connectiongetConnection(String,java.util.Properties,boolean)
public static DefaultContext getConnection(java.lang.String url, boolean autoCommit) throws java.sql.SQLException
Notes:
url
- the database urlautoCommit
- true if the connection should be created in
auto-commit mode, false otherwisepublic static DefaultContext getConnection(java.lang.String url) throws java.sql.SQLException
Notes:
url
- the database urlgetConnection(String,boolean)
public static DefaultContext getConnection(ConnectionContext other) throws java.sql.SQLException
Notes:
other
- the context with which to share an underlying connection.public static DefaultContext getConnection(java.lang.Class loadCtx, java.lang.String propName, boolean autoCommit) throws java.sql.SQLException
The property file is loaded as a resource file using the class loader of the passed "loadCtx" class. If the class loader of the passed class is null, then the file is loaded as a system resource.
The name of the property file to use is determined by "propName". If "propName" is null, then the name "sqlj.properties" is used. If the "propName" name starts with "/", it is used as is. Otherwise, the name of the package of "loadCtx" is prepended, after converting "." to "/". These naming conventions mirror those defined by Class.getResourceAsStream().
Notes:
loadCtx
- the class used to load the properties filepropName
- the name of the properties file to loadautoCommit
- true if the connection should be created in
auto-commit mode, false otherwiseClass.getResourceAsStream(java.lang.String)
,
SQLJ_PROPERTIES
,
USER_KEY
,
URL_KEY
,
PASSWORD_KEY
public static DefaultContext getConnection(java.lang.Class loadCtx, java.lang.String propName) throws java.sql.SQLException
The property file is loaded as a resource file using the class loader of the passed "loadCtx" class. If the class loader of the passed class is null, then the file is loaded as a system resource.
The name of the property file to use is determined by "propName". If "propName" is null, then the name "sqlj.properties" is used. If the "propName" name starts with "/", it is used as is. Otherwise, the name of the package of "loadCtx" is prepended, after converting "." to "/". These naming conventions mirror those defined by Class.getResourceAsStream().
Notes:
loadCtx
- the class used to load the properties filepropName
- the name of the properties file to loadClass.getResourceAsStream(java.lang.String)
,
SQLJ_PROPERTIES
,
USER_KEY
,
URL_KEY
,
PASSWORD_KEY
,
getConnection(Class, String, boolean)
public static DefaultContext getConnection(java.lang.Class loadCtx, java.lang.String propName, java.lang.String user, java.lang.String password, boolean autoCommit) throws java.sql.SQLException
The property file is loaded as a resource file using the class loader of the passed "loadCtx" class. If the class loader of the passed class is null, then the file is loaded as a system resource.
The name of the property file to use is determined by "propName". If "propName" is null, then the name "sqlj.properties" is used. If the "propName" name starts with "/", it is used as is. Otherwise, the name of the package of "loadCtx" is prepended, after converting "." to "/". These naming conventions mirror those defined by Class.getResourceAsStream().
Notes:
loadCtx
- the class used to load the properties filepropName
- the name of the properties file to loaduser
- the usernamepassword
- the user passwordautoCommit
- true if the connection should be created in
auto-commit mode, false otherwiseClass.getResourceAsStream(java.lang.String)
,
SQLJ_PROPERTIES
,
USER_KEY
,
URL_KEY
,
PASSWORD_KEY
public static DefaultContext getConnection(java.lang.Class loadCtx, java.lang.String propName, java.lang.String user, java.lang.String password) throws java.sql.SQLException
The property file is loaded as a resource file using the class loader of the passed "loadCtx" class. If the class loader of the passed class is null, then the file is loaded as a system resource.
The name of the property file to use is determined by "propName". If "propName" is null, then the name "sqlj.properties" is used. If the "propName" name starts with "/", it is used as is. Otherwise, the name of the package of "loadCtx" is prepended, after converting "." to "/". These naming conventions mirror those defined by Class.getResourceAsStream().
Notes:
loadCtx
- the class used to load the properties filepropName
- the name of the properties file to loaduser
- the usernamepassword
- the user passwordClass.getResourceAsStream(java.lang.String)
,
SQLJ_PROPERTIES
,
USER_KEY
,
URL_KEY
,
PASSWORD_KEY
,
getConnection(Class, String, String, String, boolean)
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |