All Packages    This Package  Previous  Next  

Class sqlj.runtime.ref.DefaultContext

java.lang.Object
   |
   +----sqlj.runtime.ref.ConnectionContextImpl
           |
           +----sqlj.runtime.ref.DefaultContext

public class DefaultContext
extends ConnectionContextImpl
implements ConnectionContext
The default context class provides a complete default implementation of a connection context. This is the same class definition that would have been generated by the reference translator for the clause: #sql public context DefaultContext; The reference implementation defaults to this class when no connection context instance variable exists in an executable sql clause and no other default class name was provided to the translator.


Constructor Index

 o DefaultContext(Connection)
Creates a new default context instance which uses the passed connection as its underlying connection.
 o DefaultContext(ConnectionContext)
Creates a new default context instance which uses the same underlying connection as the passed connection context instance.
 o DefaultContext(String, boolean)
Creates a new default context instance whose underlying connection is created based on the passed url.
 o DefaultContext(String, Properties, boolean)
Creates a new default context instance whose underlying connection is created based on the passed url, and properties information.
 o DefaultContext(String, String, String, boolean)
Creates a new default context instance whose underlying connection is created based on the passed url, user and password.

Method Index

 o getDefaultContext()
Returns the default context instance associated with this context class.
 o getProfile(Object)
Returns a top-level profile associated with profile key returned by an earlier call to getProfileKey in this context class.
 o getProfileKey(Loader, String)
Returns a key associated with the profile having the given name.
 o setDefaultContext(DefaultContext)
Sets the default connection context to be used for this class.

Constructors

 o DefaultContext
 public DefaultContext(Connection conn) throws SQLException
Creates a new default context instance which uses the passed connection as its underlying connection. The auto commit mode of the connection is used unchanged.

Note that the passed connection will not be closed if a call to this constructor results in an exception

Parameters:
conn - the underlying connection for this context instance.
Throws: SQLException
if an instance could not be constructed
 o DefaultContext
 public DefaultContext(String url,
                       String user,
                       String password,
                       boolean autoCommit) throws SQLException
Creates a new default context instance whose underlying connection is created based on the passed url, user and password.

Note that if an exception occurs during construction, the underlying connection created during this call will be automatically closed.

Parameters:
url - the database url
user - the username
password - the user password
autoCommit - true if the connection should be created in auto-commit mode, false otherwise
Throws: SQLException
the underlying connection could not be created.
See Also:
getConnection, setAutoCommit
 o DefaultContext
 public DefaultContext(String url,
                       Properties info,
                       boolean autoCommit) throws SQLException
Creates a new default context instance whose underlying connection is created based on the passed url, and properties information.

Note that if an exception occurs during construction, the underlying connection created during this call will be automatically closed.

Parameters:
url - the database url
info - a list of properties for the connection
autoCommit - true if the connection should be created in auto-commit mode, false otherwise
autoCommit - true if the connection should be created in auto-commit mode, false otherwise
Throws: SQLException
the underlying connection could not be created.
See Also:
getConnection, setAutoCommit
 o DefaultContext
 public DefaultContext(String url,
                       boolean autoCommit) throws SQLException
Creates a new default context instance whose underlying connection is created based on the passed url.

Note that if an exception occurs during construction, the underlying connection created during this call will be automatically closed.

Parameters:
url - the database url
autoCommit - true if the connection should be created in auto-commit mode, false otherwise
Throws: SQLException
the underlying connection could not be created.
See Also:
getConnection, setAutoCommit
 o DefaultContext
 public DefaultContext(ConnectionContext other) throws SQLException
Creates a new default context instance which uses the same underlying connection as the passed connection context instance. The auto commit mode of the shared connection is used unchanged.

Note that the passed other ConnectionContext (and its underlying connection) will not be closed if a call to this constructor results in an exception.

Parameters:
other - the context with which to share an underlying connection.
Throws: SQLException
if an instance could not be constructed
See Also:
sqlj.runtime.ref.DefaultContext, getConnection

Methods

 o getProfileKey
 public static Object getProfileKey(Loader loader,
                                    String profileName) throws SQLException
Returns a key associated with the profile having the given name. If the key for a profile with this name already exists, it is returned. Otherwise, a new profile is registered with the given name and loader and a new key for this profile is returned. An exception is raised a profile cannot be loaded with the given name and loader.

Parameters:
loader - the profile loader from which the profile should be loaded if it doesn't already exist.
profileName - the fully qualified name of the profile.
Returns:
a key for the profile with the given name in this context.
Throws: SQLException
if a profile with this name cannot be loaded.
See Also:
getProfile, getConnectedProfile
 o getProfile
 public static Profile getProfile(Object profileKey)
Returns a top-level profile associated with profile key returned by an earlier call to getProfileKey in this context class. Each connection context class maintains a set of profiles that collectively define all possible sql operations that may be performed on this context.

Parameters:
profileKey - the key asscoiated with the desired profile.
Throws: IllegalArgumentException
if the profileKey is null or invalid.
See Also:
getProfileKey
 o getDefaultContext
 public static DefaultContext getDefaultContext()
Returns the default context instance associated with this context class. If a default context has been explicitely installed via a call to setDefaultContext, that context is returned. Otherwise, if a default JDBC connection exists in the current runtime context, a new default context object is created, installed and returned which uses the default JDBC connection as its underlying connection. If no default connection exists in the runtime, null is returned.

See Also:
setDefaultContext, getDefaultConnection
 o setDefaultContext
 public static void setDefaultContext(DefaultContext ctx)
Sets the default connection context to be used for this class. Any previous default context is replaced.

Parameters:
ctx - the new default context instance.

All Packages    This Package  Previous  Next