com.javactionscript.server
Class ContextualDatabase

java.lang.Object
  extended by com.javactionscript.server.ContextualDatabase

public class ContextualDatabase
extends java.lang.Object

This resource allows to execute transactional SQL operations in a DBMS. The transaction will start at the RemoteTransaction creation and end with a commit at the RemoteTransaction successful closing or stop with a rollback if an error occurred during the execution of the commands.
It can be configured once for all through ContextFactory.getDatabaseProperties() and then used during the command execution through the ServiceContext object.
A ContextualDatabase resource can be obtained from a ServiceContext instance.


Method Summary
 java.sql.ResultSet executeSql(java.lang.String $sql, java.lang.Object[] $parameters)
          Creates and execute a PreparedStatement and returns the corresponding ResultSet if the statement is a SELECT query.
 java.util.Date executeSqlReturnDate(java.lang.String $sql, java.lang.Object[] $parameters)
          Calls executeSql(String, Object[]) and returns the first cell of the first row of the resultset.
 java.lang.Double executeSqlReturnDouble(java.lang.String $sql, java.lang.Object[] $parameters)
          Calls executeSql(String, Object[]) and returns the first cell of the first row of the resultset.
 java.lang.Integer executeSqlReturnInteger(java.lang.String $sql, java.lang.Object[] $parameters)
          Calls executeSql(String, Object[]) and returns the first cell of the first row of the resultset.
 java.lang.Long executeSqlReturnLong(java.lang.String $sql, java.lang.Object[] $parameters)
          Calls executeSql(String, Object[]) and returns the first cell of the first row of the resultset.
 java.lang.String executeSqlReturnString(java.lang.String $sql, java.lang.Object[] $parameters)
          Calls executeSql(String, Object[]) and returns the first cell of the first row of the resultset.
 java.sql.Connection getConnection()
          Returns the underlying Connection that was retrieved from the pool and dedicated to this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

executeSql

public java.sql.ResultSet executeSql(java.lang.String $sql,
                                     java.lang.Object[] $parameters)
                              throws java.sql.SQLException
Creates and execute a PreparedStatement and returns the corresponding ResultSet if the statement is a SELECT query.

Parameters:
$sql - the SQL command for the PreparedStatement. Remember that it is never recommended to build your statement from request parameters because of possible SQL-injection attacks (use $parameters instead).
$parameters - the parameters that will replace the question marks in the SQL command.
Returns:
ResultSet the corresponding ResultSet if the statement is a SELECT query, or null otherwise.
Throws:
java.sql.SQLException

executeSqlReturnDouble

public java.lang.Double executeSqlReturnDouble(java.lang.String $sql,
                                               java.lang.Object[] $parameters)
                                        throws java.sql.SQLException
Calls executeSql(String, Object[]) and returns the first cell of the first row of the resultset.

Parameters:
$sql - the SQL command for the PreparedStatement. Remember that it is never recommended to build your statement from request parameters because of possible SQL-injection attacks (use $parameters instead).
$parameters - the parameters that will replace the question marks in the SQL command.
Returns:
the first cell of the first row as a Double, or null if the statement returned an empty ResultSet or no ResultSet at all.
Throws:
java.sql.SQLException

executeSqlReturnString

public java.lang.String executeSqlReturnString(java.lang.String $sql,
                                               java.lang.Object[] $parameters)
                                        throws java.sql.SQLException
Calls executeSql(String, Object[]) and returns the first cell of the first row of the resultset.

Parameters:
$sql - the SQL command for the PreparedStatement. Remember that it is never recommended to build your statement from request parameters because of possible SQL-injection attacks (use $parameters instead).
$parameters - the parameters that will replace the question marks in the SQL command.
Returns:
the first cell of the first row as a String, or null if the statement returned an empty ResultSet or no ResultSet at all.
Throws:
java.sql.SQLException

executeSqlReturnLong

public java.lang.Long executeSqlReturnLong(java.lang.String $sql,
                                           java.lang.Object[] $parameters)
                                    throws java.sql.SQLException
Calls executeSql(String, Object[]) and returns the first cell of the first row of the resultset.

Parameters:
$sql - the SQL command for the PreparedStatement. Remember that it is never recommended to build your statement from request parameters because of possible SQL-injection attacks (use $parameters instead).
$parameters - the parameters that will replace the question marks in the SQL command.
Returns:
the first cell of the first row as a Long, or null if the statement returned an empty ResultSet or no ResultSet at all.
Throws:
java.sql.SQLException

executeSqlReturnDate

public java.util.Date executeSqlReturnDate(java.lang.String $sql,
                                           java.lang.Object[] $parameters)
                                    throws java.sql.SQLException
Calls executeSql(String, Object[]) and returns the first cell of the first row of the resultset.

Parameters:
$sql - the SQL command for the PreparedStatement. Remember that it is never recommended to build your statement from request parameters because of possible SQL-injection attacks (use $parameters instead).
$parameters - the parameters that will replace the question marks in the SQL command.
Returns:
the first cell of the first row as a Date, or null if the statement returned an empty ResultSet or no ResultSet at all.
Throws:
java.sql.SQLException

executeSqlReturnInteger

public java.lang.Integer executeSqlReturnInteger(java.lang.String $sql,
                                                 java.lang.Object[] $parameters)
                                          throws java.sql.SQLException
Calls executeSql(String, Object[]) and returns the first cell of the first row of the resultset.

Parameters:
$sql - the SQL command for the PreparedStatement. Remember that it is never recommended to build your statement from request parameters because of possible SQL-injection attacks (use $parameters instead).
$parameters - the parameters that will replace the question marks in the SQL command.
Returns:
the first cell of the first row as a Integer, or null if the statement returned an empty ResultSet or no ResultSet at all.
Throws:
java.sql.SQLException

getConnection

public java.sql.Connection getConnection()
Returns the underlying Connection that was retrieved from the pool and dedicated to this object.

Returns:
the Connection instance.


Copyright 2008 LUNAFELINA - www.javactionscript.com - www.lunafelina.com