* [ 1644635 ] WAN: DB.prepareCall not working

This commit is contained in:
Heng Sin Low 2007-01-29 05:10:50 +00:00
parent fd7c2c9b12
commit e75b04f535
1 changed files with 33 additions and 8 deletions

View File

@ -743,22 +743,47 @@ public final class DB
log.fine("closed");
} // closeTarget
/**************************************************************************
* Prepare Forward Read Only Call
* @param RO_SQL sql (RO)
* @param SQL sql
* @return Callable Statement
*/
public static CallableStatement prepareCall(String RO_SQL)
public static CallableStatement prepareCall(String sql)
{
if (RO_SQL == null || RO_SQL.length() == 0)
throw new IllegalArgumentException("Required parameter missing - " + RO_SQL);
return prepareCall(sql, ResultSet.CONCUR_UPDATABLE, null);
}
/**************************************************************************
* Prepare Call
* @param SQL sql
* @param readOnly
* @param trxName
* @return Callable Statement
*/
public static CallableStatement prepareCall(String SQL, int resultSetConcurrency, String trxName)
{
if (SQL == null || SQL.length() == 0)
throw new IllegalArgumentException("Required parameter missing - " + SQL);
//
String sql = getDatabase().convertStatement(RO_SQL);
String sql = getDatabase().convertStatement(SQL);
try
{
return getConnectionRO().prepareCall
(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
Connection conn = null;
Trx trx = trxName == null ? null : Trx.get(trxName, true);
if (trx != null)
conn = trx.getConnection();
else
{
if (resultSetConcurrency == ResultSet.CONCUR_UPDATABLE)
conn = DB.getConnectionRW ();
else
conn = DB.getConnectionRO();
}
if (conn == null)
throw new DBException("No Connection");
return conn.prepareCall
(sql, ResultSet.TYPE_FORWARD_ONLY, resultSetConcurrency);
}
catch (SQLException e)
{