pt.moredata.dao.core
Class SQLStatementCache

java.lang.Object
  extended bypt.moredata.dao.core.SQLStatementCache

public class SQLStatementCache
extends java.lang.Object

This class is responsibly for prepare SQL statemends and cache SQL prepared statements. This class is not thread safe. Company MoreData

Version:
$Revision: 1.4 $ TODO : E necessario acrescentar um mecanismo que permita fechar os statements e assim libertar os recursos. Um metodo com o nome closeStatement(String statement) deve ser o suficiente.
Author:
pcarmo

Constructor Summary
SQLStatementCache(java.sql.Connection connection)
          Creates a new instance of SQLStatementCache.
 
Method Summary
 java.sql.PreparedStatement getPreparedStatement(java.lang.String statement)
          Return a prepared statement for a giveen sql statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLStatementCache

public SQLStatementCache(java.sql.Connection connection)
Creates a new instance of SQLStatementCache.

Parameters:
connection - A DataBase connection to prepare the sql statements.
Method Detail

getPreparedStatement

public java.sql.PreparedStatement getPreparedStatement(java.lang.String statement)
                                                throws java.sql.SQLException
Return a prepared statement for a giveen sql statement.

Parameters:
statement - The statement to be prepared.
Returns:
A prepared sql startement for the giveen statement or a previous prepared statement it was prepared before.
Throws:
java.sql.SQLException - If a error occurs during the preparation of the sql statement.