Class TConnection
Represents a connection to a relational
database. It is also used to maintain a transaction context.
Every TConnection starts its life with autocommit mode
turned on. See TConnection autocommit
for a more detailed explanation.
Before creating any instances of this class at least one JDBC driver
must have been previously successfully registered by a call to
tdbc-register-driver.
autocommit flag
Sets the autocommit mode for this TConnection
|
close
Closes the connection to the database.
|
commit
Commits all the changes made to the database since the start of
the transaction.
|
connect url [username password]
Opens a connection to a database.
|
constructor [url [username password]]
Initializes the object and, optionally, opens a connection to a
database.
|
prepare sqlStatement
Creates a pre-compiled statement object.
|
prepareCall sqlStatement
Creates a pre-compiled statement object to execute stored procedures.
|
rollback
Undoes all the changes made to the database since the start of
the transaction.
|
statement
Creates a TStatement object in order to execute
SQL statements.
|
|
autocommit
TConnection autocommit flag
Sets the autocommit mode for this TConnection
- Parameters:
- flag -
- Returns:
-
A reference to the object for which this method was called.
-
If the flag argument is true then every change in the
database made through a TStatement created
by this TConnection will be implicitly followed
by a TConnection commit. In this
mode it is not possible to to a rollback.
If the flag argument is false then changes to
the database made through a TStatement created
by this TConnection will require a call to
TConnection commit to become
permanent.
close
TConnection close
Closes the connection to the database.
-
Closes the connection to the database. The object can then no longer
be used. All the changes made to the database since the start of the
current transaction are rolled back. All the
TStatement,
TPreparedStatement,
TCallableStatement
objects created by this TConnection that are still
open are automatically closed.
commit
TConnection commit
Commits all the changes made to the database since the start of
the transaction.
- Returns:
-
A reference to the TConnection for which this method
was called.
-
The database transaction represented by this
TConnection was implicitly started when this
TConnection was created or at the last call
to the TConnection commit or
TConnection rollback methods.
A new transaction is implicitly started when this method
terminates successfully.
connect
TConnection connect url [username password]
Opens a connection to a database.
- Parameters:
- url -
String identifying the database to connect to.
- username -
String identifying a user connecting to the database.
- password -
String representing a password associated with username.
-
If a connection was previsouly opened then it is automatically
closed before atempting to establish the new connection.
When a connection to the database is successfully established
a database transaction transaction is also implicitly initiated.
The url identifying the database is dependent on the
type of database. You must consult the documentation for the JDBC
driver being used in order to specify a meaningful URL.
constructor
TConnection constructor [url [username password]]
Initializes the object and, optionally, opens a connection to a
database.
- Parameters:
- url -
String identifying the database to connect to.
- username -
String identifying a user connecting to the database.
- password -
String representing a password associated with username.
-
When the constructor receives arguments a call to the
connect is implicitly performed, thus
establishing the connection to the database.
When a TConnection is instantiated a transaction is
also initiated.
The url identifying the database is dependent on the
type of database. You must consult the documentation for the JDBC
driver being used in order to specify a meaningful URL.
prepare
TConnection prepare sqlStatement
Creates a pre-compiled statement object.
- Returns:
-
A reference to a new TPreparedStatement
representing the precompiled sqlStatement.
-
Creates an instance of a TPreparedStatement
representing
a pre-compiled SQL statement whose contents are given by the
sqlStatement argument.
You create a TPreparedStatement when you
intend to execute multiple SQL statements that differ only
in the values of certain parameters. Using a
TPreparedStatement in situations as this
may bring noticeable performance improvements.
prepareCall
TConnection prepareCall sqlStatement
Creates a pre-compiled statement object to execute stored procedures.
- Returns:
-
A reference to a new TPreparedStatement representing
the precompiled sqlStatement.
-
Creates an instance of a TCallableStatement
representing
a pre-compiled SQL statement whose contents are given by the
sqlStatement argument. You use a
TCallableStatement when executing stored
procedures in the database server.
rollback
TConnection rollback
Undoes all the changes made to the database since the start of
the transaction.
- Returns:
-
A reference to the TConnection for which this method
was called.
-
The database transaction represented by this
TConnection was implicitly started when this
TConnection was created or at the last call
to the TConnection commit or
TConnection rollback methods.
A new transaction is implicitly started when this method
terminates successfully.
statement
TConnection statement
Creates a TStatement object in order to execute
SQL statements.
- Returns:
-
A reference to the newly created TStatement object.
-
Report a bug or request new features
© 2002