LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.peer.sql
Class LySqlConnection

java.lang.Object
  extended by leon.peer.LyConnection
      extended by leon.peer.sql.LySqlConnection
Direct Known Subclasses:
LyAccessConnection, LyHsqldbConnection, LyMySqlConnection

public class LySqlConnection
extends LyConnection

This class is used as a connection for relational database.

See Also:
LyConnection

Field Summary
static java.lang.String __VERSION
           
static int STATEMENT_TIMEOUT
          Default statement timeout
 
Constructor Summary
LySqlConnection(LyApplication application, java.lang.String name)
          Constructor.
LySqlConnection(LyApplication application, java.lang.String name, javax.sql.DataSource dataSource)
          Constructor.
 
Method Summary
 void autoCommit(boolean status)
          To change the autoCommit mode of the JDBC connection.
 boolean close()
          Close the physical connection to the database.
 void commit()
          To commit a pending transaction for this connection.
 java.sql.Connection getConnection()
          Gets connection to the database.
 java.sql.DatabaseMetaData getMetaData()
          To get meta-information from the database.
 java.util.Properties getProperties()
          To get the properties of this SQL connection.
 java.sql.Statement getStatement()
          Gets current statement to the database.
 void handleError(java.sql.SQLException e)
          Method to handle SQLException.
 boolean open(java.lang.String username, java.lang.String password)
          Open the physical connection to the database.
 boolean open(java.lang.String username, java.lang.String password, java.lang.String driverName)
          Open the physical connection to the database.
 void released()
          Connection released.
 void rollback()
          To rollback a pending transaction for this connection.
 java.sql.ResultSet sendQueryRequest(java.lang.String request)
          Sends a request to the database.
 java.sql.ResultSet sendQueryRequest(java.lang.String request, int limit)
          Sends a request to the database.
 int sendUpdateRequest(java.lang.String request)
          Sends a request to the database.
 void setStatementTimeout(int statementTimeout)
          Sets the _statementTimeout attribute for current connection.
 
Methods inherited from class leon.peer.LyConnection
addValue, dump, getError, getUID, getValue, isClosed, isReserved, prepareCommit, reserved, setDataProvider, setError, setUID
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
See Also:
Constant Field Values

STATEMENT_TIMEOUT

public static int STATEMENT_TIMEOUT
Default statement timeout

Constructor Detail

LySqlConnection

public LySqlConnection(LyApplication application,
                       java.lang.String name)
Constructor.

Parameters:
application - Application of the data provider that manages this connection.
name - Name of the database.

LySqlConnection

public LySqlConnection(LyApplication application,
                       java.lang.String name,
                       javax.sql.DataSource dataSource)
Constructor.

Parameters:
application - Application of the data provider that manages this connection.
name - Name of the database.
dataSource - JDBC DataSource providing the JDBC connection.
Method Detail

setStatementTimeout

public void setStatementTimeout(int statementTimeout)
Sets the _statementTimeout attribute for current connection.

Parameters:
statementTimeout - new value for the _statementTimeout attribute

open

public boolean open(java.lang.String username,
                    java.lang.String password)
Open the physical connection to the database.

Parameters:
username - user id.
password - user password.
Returns:
true : connection established, false : connection refused

open

public boolean open(java.lang.String username,
                    java.lang.String password,
                    java.lang.String driverName)
Open the physical connection to the database.

Parameters:
username - user id.
password - user password.
driverName - The driver class name.
Returns:
true : connection established, false : connection refused

close

public boolean close()
Close the physical connection to the database.

Overrides:
close in class LyConnection
Returns:
true : connection is closed, false : an error occured.

released

public void released()
Connection released.

Overrides:
released in class LyConnection

getProperties

public java.util.Properties getProperties()
To get the properties of this SQL connection.

Returns:
The properties of this connection.

getMetaData

public java.sql.DatabaseMetaData getMetaData()
To get meta-information from the database.

Returns:
the meta-information of the database.

sendQueryRequest

public java.sql.ResultSet sendQueryRequest(java.lang.String request)
Sends a request to the database. The request type must be : select, count.

Parameters:
request - the sql request.
Returns:
the ResultSet returned by the driver.

sendQueryRequest

public java.sql.ResultSet sendQueryRequest(java.lang.String request,
                                           int limit)
Sends a request to the database. The request type must be : select, count.

Parameters:
request - the sql request.
limit - maximum number of rows to fetch (-1 for no limit)
Returns:
the ResultSet returned by the driver.

sendUpdateRequest

public int sendUpdateRequest(java.lang.String request)
Sends a request to the database. The request type must be : set, create, delete.

Parameters:
request - the sql request.
Returns:
the number of lines returned by the driver.

handleError

public void handleError(java.sql.SQLException e)
Method to handle SQLException.

Parameters:
e - SQLEXception to handle.

commit

public void commit()
Description copied from class: LyConnection
To commit a pending transaction for this connection.

Overrides:
commit in class LyConnection

rollback

public void rollback()
Description copied from class: LyConnection
To rollback a pending transaction for this connection.

Overrides:
rollback in class LyConnection

autoCommit

public void autoCommit(boolean status)
To change the autoCommit mode of the JDBC connection.

Overrides:
autoCommit in class LyConnection
Parameters:
status - the new mode.

getConnection

public java.sql.Connection getConnection()
Gets connection to the database. Warning ! Any modification on the returned object may cause major dysfunctions.

Returns:
The connection to the database.

getStatement

public java.sql.Statement getStatement()
Gets current statement to the database. Warning ! Any modification on the returned object may cause major dysfunctions.

Returns:
The current statement.

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com