Compiere 3.1

org.compiere.util
Class CStatement

java.lang.Object
  extended by org.compiere.util.CStatement
All Implemented Interfaces:
Statement, Wrapper
Direct Known Subclasses:
CPreparedStatement

public class CStatement
extends Object
implements Statement

Compiere Statement

Version:
$Id: CStatement.java,v 1.3 2006/07/30 00:54:36 jjanke Exp $
Author:
Jorg Janke

Field Summary
protected  CLogger log
          Logger
protected  int p_remoteErrors
          Remote Errors
protected  Statement p_stmt
          Used if local
protected  CStatementVO p_vo
          Value Object
 
Fields inherited from interface java.sql.Statement
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO
 
Constructor Summary
protected CStatement()
          Minimum Constructor for sub classes
  CStatement(CStatementVO vo)
          Remote Constructor
  CStatement(int resultSetType, int resultSetConcurrency, String trxName)
          Prepared Statement Constructor
 
Method Summary
 void addBatch(String sql)
          Add Batch
 void cancel()
          Method cancel
 void clearBatch()
          Method clearBatch
 void clearWarnings()
          Method clearWarnings
 void close()
          Close
 void commit()
          Commit (if local)
 boolean execute(String sql0)
          Method execute
 boolean execute(String sql0, int autoGeneratedKeys)
          Method execute
 boolean execute(String sql0, int[] columnIndexes)
          Method execute
 boolean execute(String sql0, String[] columnNames)
          Method execute
 int[] executeBatch()
          Method executeBatch
 ResultSet executeQuery(String sql0)
          Execute Query
 int executeUpdate(String sql0)
          Execute Update
 int executeUpdate(String sql0, int autoGeneratedKeys)
          Method executeUpdate
 int executeUpdate(String sql0, int[] columnIndexes)
          Method executeUpdate
 int executeUpdate(String sql0, String[] columnNames)
          Method executeUpdate
 Connection getConnection()
          Get Connection
 int getFetchDirection()
          Method getFetchDirection
 int getFetchSize()
          Method getFetchSize
 ResultSet getGeneratedKeys()
          Method getGeneratedKeys
 int getMaxFieldSize()
          Get Max Field Size
 int getMaxRows()
          Method getMaxRows
 boolean getMoreResults()
          Method getMoreResults
 boolean getMoreResults(int current)
          Method getMoreResults
 int getQueryTimeout()
          Method getQueryTimeout
 ResultSet getResultSet()
          Method getResultSet
 int getResultSetConcurrency()
          Method getResultSetConcurrency
 int getResultSetHoldability()
          Method getResultSetHoldability
 int getResultSetType()
          Method getResultSetType
 String getSql()
          Get Sql
 int getUpdateCount()
          Method getUpdateCount
 SQLWarning getWarnings()
          Method getWarnings
 boolean isClosed()
          isClosed
 boolean isPoolable()
          isPoolable
 boolean isWrapperFor(Class<?> iface)
          isWrapperFor
protected  Connection local_getConnection(String trxName)
          Get Local Connection
 int remote_executeUpdate()
          Execute Update.
 RowSet remote_getRowSet()
          Get Result as RowSet for Remote.
 void setCursorName(String name)
          Method setCursorName
 void setEscapeProcessing(boolean enable)
          Method setEscapeProcessing
 void setFetchDirection(int direction)
          Method setFetchDirection
 void setFetchSize(int rows)
          Method setFetchSize
 void setMaxFieldSize(int max)
          Method setMaxFieldSize
 void setMaxRows(int max)
          Method setMaxRows
 void setPoolable(boolean poolable)
          setPoolable
 void setQueryTimeout(int seconds)
          Method setQueryTimeout
<T> T
unwrap(Class<T> iface)
          unwrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected transient CLogger log
Logger


p_stmt

protected transient Statement p_stmt
Used if local


p_vo

protected CStatementVO p_vo
Value Object


p_remoteErrors

protected int p_remoteErrors
Remote Errors

Constructor Detail

CStatement

public CStatement(int resultSetType,
                  int resultSetConcurrency,
                  String trxName)
Prepared Statement Constructor

Parameters:
resultSetType - - ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency - - ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
trxName - transaction name or null

CStatement

protected CStatement()
Minimum Constructor for sub classes


CStatement

public CStatement(CStatementVO vo)
Remote Constructor

Parameters:
vo - value object
Method Detail

executeQuery

public ResultSet executeQuery(String sql0)
                       throws SQLException
Execute Query

Specified by:
executeQuery in interface Statement
Parameters:
sql0 - unconverted SQL to execute
Returns:
ResultSet or RowSet
Throws:
SQLException
See Also:
Statement.executeQuery(String)

executeUpdate

public int executeUpdate(String sql0)
                  throws SQLException
Execute Update

Specified by:
executeUpdate in interface Statement
Parameters:
sql0 - unconverted sql
Returns:
no of updated rows
Throws:
SQLException
See Also:
Statement.executeUpdate(String)

getSql

public String getSql()
Get Sql

Returns:
sql

getConnection

public Connection getConnection()
                         throws SQLException
Get Connection

Specified by:
getConnection in interface Statement
Returns:
connection for local - or null for remote
Throws:
SQLException
See Also:
Statement.getConnection()

commit

public void commit()
            throws SQLException
Commit (if local)

Throws:
SQLException

executeUpdate

public int executeUpdate(String sql0,
                         int autoGeneratedKeys)
                  throws SQLException
Method executeUpdate

Specified by:
executeUpdate in interface Statement
Parameters:
sql0 - String
autoGeneratedKeys - int
Returns:
int
Throws:
SQLException
See Also:
Statement.executeUpdate(String, int)

executeUpdate

public int executeUpdate(String sql0,
                         int[] columnIndexes)
                  throws SQLException
Method executeUpdate

Specified by:
executeUpdate in interface Statement
Parameters:
sql0 - String
columnIndexes - int[]
Returns:
int
Throws:
SQLException
See Also:
Statement.executeUpdate(String, int[])

executeUpdate

public int executeUpdate(String sql0,
                         String[] columnNames)
                  throws SQLException
Method executeUpdate

Specified by:
executeUpdate in interface Statement
Parameters:
sql0 - String
columnNames - String[]
Returns:
int
Throws:
SQLException
See Also:
Statement.executeUpdate(String, String[])

execute

public boolean execute(String sql0)
                throws SQLException
Method execute

Specified by:
execute in interface Statement
Parameters:
sql0 - String
Returns:
boolean
Throws:
SQLException
See Also:
Statement.execute(String)

execute

public boolean execute(String sql0,
                       int autoGeneratedKeys)
                throws SQLException
Method execute

Specified by:
execute in interface Statement
Parameters:
sql0 - String
autoGeneratedKeys - int
Returns:
boolean
Throws:
SQLException
See Also:
Statement.execute(String, int)

execute

public boolean execute(String sql0,
                       int[] columnIndexes)
                throws SQLException
Method execute

Specified by:
execute in interface Statement
Parameters:
sql0 - String
columnIndexes - int[]
Returns:
boolean
Throws:
SQLException
See Also:
Statement.execute(String, int[])

execute

public boolean execute(String sql0,
                       String[] columnNames)
                throws SQLException
Method execute

Specified by:
execute in interface Statement
Parameters:
sql0 - String
columnNames - String[]
Returns:
boolean
Throws:
SQLException
See Also:
Statement.execute(String, String[])

getMaxFieldSize

public int getMaxFieldSize()
                    throws SQLException
Get Max Field Size

Specified by:
getMaxFieldSize in interface Statement
Returns:
field size
Throws:
SQLException
See Also:
Statement.getMaxFieldSize()

setMaxFieldSize

public void setMaxFieldSize(int max)
                     throws SQLException
Method setMaxFieldSize

Specified by:
setMaxFieldSize in interface Statement
Parameters:
max - int
Throws:
SQLException
See Also:
Statement.setMaxFieldSize(int)

getMaxRows

public int getMaxRows()
               throws SQLException
Method getMaxRows

Specified by:
getMaxRows in interface Statement
Returns:
int
Throws:
SQLException
See Also:
Statement.getMaxRows()

setMaxRows

public void setMaxRows(int max)
                throws SQLException
Method setMaxRows

Specified by:
setMaxRows in interface Statement
Parameters:
max - int
Throws:
SQLException
See Also:
Statement.setMaxRows(int)

addBatch

public void addBatch(String sql)
              throws SQLException
Add Batch

Specified by:
addBatch in interface Statement
Parameters:
sql - sql
Throws:
SQLException
See Also:
Statement.addBatch(String)

clearBatch

public void clearBatch()
                throws SQLException
Method clearBatch

Specified by:
clearBatch in interface Statement
Throws:
SQLException
See Also:
Statement.clearBatch()

executeBatch

public int[] executeBatch()
                   throws SQLException
Method executeBatch

Specified by:
executeBatch in interface Statement
Returns:
int[]
Throws:
SQLException
See Also:
Statement.executeBatch()

getMoreResults

public boolean getMoreResults(int current)
                       throws SQLException
Method getMoreResults

Specified by:
getMoreResults in interface Statement
Parameters:
current - int
Returns:
boolean
Throws:
SQLException
See Also:
Statement.getMoreResults(int)

getGeneratedKeys

public ResultSet getGeneratedKeys()
                           throws SQLException
Method getGeneratedKeys

Specified by:
getGeneratedKeys in interface Statement
Returns:
ResultSet
Throws:
SQLException
See Also:
Statement.getGeneratedKeys()

getResultSetHoldability

public int getResultSetHoldability()
                            throws SQLException
Method getResultSetHoldability

Specified by:
getResultSetHoldability in interface Statement
Returns:
int
Throws:
SQLException
See Also:
Statement.getResultSetHoldability()

setEscapeProcessing

public void setEscapeProcessing(boolean enable)
                         throws SQLException
Method setEscapeProcessing

Specified by:
setEscapeProcessing in interface Statement
Parameters:
enable - boolean
Throws:
SQLException
See Also:
Statement.setEscapeProcessing(boolean)

getQueryTimeout

public int getQueryTimeout()
                    throws SQLException
Method getQueryTimeout

Specified by:
getQueryTimeout in interface Statement
Returns:
int
Throws:
SQLException
See Also:
Statement.getQueryTimeout()

setQueryTimeout

public void setQueryTimeout(int seconds)
                     throws SQLException
Method setQueryTimeout

Specified by:
setQueryTimeout in interface Statement
Parameters:
seconds - int
Throws:
SQLException
See Also:
Statement.setQueryTimeout(int)

cancel

public void cancel()
            throws SQLException
Method cancel

Specified by:
cancel in interface Statement
Throws:
SQLException
See Also:
Statement.cancel()

getWarnings

public SQLWarning getWarnings()
                       throws SQLException
Method getWarnings

Specified by:
getWarnings in interface Statement
Returns:
SQLWarning
Throws:
SQLException
See Also:
Statement.getWarnings()

clearWarnings

public void clearWarnings()
                   throws SQLException
Method clearWarnings

Specified by:
clearWarnings in interface Statement
Throws:
SQLException
See Also:
Statement.clearWarnings()

setCursorName

public void setCursorName(String name)
                   throws SQLException
Method setCursorName

Specified by:
setCursorName in interface Statement
Parameters:
name - String
Throws:
SQLException
See Also:
Statement.setCursorName(String)

getResultSet

public ResultSet getResultSet()
                       throws SQLException
Method getResultSet

Specified by:
getResultSet in interface Statement
Returns:
ResultSet
Throws:
SQLException
See Also:
Statement.getResultSet()

getUpdateCount

public int getUpdateCount()
                   throws SQLException
Method getUpdateCount

Specified by:
getUpdateCount in interface Statement
Returns:
int
Throws:
SQLException
See Also:
Statement.getUpdateCount()

getMoreResults

public boolean getMoreResults()
                       throws SQLException
Method getMoreResults

Specified by:
getMoreResults in interface Statement
Returns:
boolean
Throws:
SQLException
See Also:
Statement.getMoreResults()

setFetchDirection

public void setFetchDirection(int direction)
                       throws SQLException
Method setFetchDirection

Specified by:
setFetchDirection in interface Statement
Parameters:
direction - int
Throws:
SQLException
See Also:
Statement.setFetchDirection(int)

getFetchDirection

public int getFetchDirection()
                      throws SQLException
Method getFetchDirection

Specified by:
getFetchDirection in interface Statement
Returns:
int
Throws:
SQLException
See Also:
Statement.getFetchDirection()

setFetchSize

public void setFetchSize(int rows)
                  throws SQLException
Method setFetchSize

Specified by:
setFetchSize in interface Statement
Parameters:
rows - int
Throws:
SQLException
See Also:
Statement.setFetchSize(int)

getFetchSize

public int getFetchSize()
                 throws SQLException
Method getFetchSize

Specified by:
getFetchSize in interface Statement
Returns:
int
Throws:
SQLException
See Also:
Statement.getFetchSize()

getResultSetConcurrency

public int getResultSetConcurrency()
                            throws SQLException
Method getResultSetConcurrency

Specified by:
getResultSetConcurrency in interface Statement
Returns:
int
Throws:
SQLException
See Also:
Statement.getResultSetConcurrency()

getResultSetType

public int getResultSetType()
                     throws SQLException
Method getResultSetType

Specified by:
getResultSetType in interface Statement
Returns:
int
Throws:
SQLException
See Also:
Statement.getResultSetType()

close

public void close()
           throws SQLException
Close

Specified by:
close in interface Statement
Throws:
SQLException
See Also:
Statement.close()

remote_executeUpdate

public int remote_executeUpdate()
Execute Update.

Returns:
row count

local_getConnection

protected Connection local_getConnection(String trxName)
Get Local Connection

Parameters:
trxName - transaction
Returns:
connection

remote_getRowSet

public RowSet remote_getRowSet()
Get Result as RowSet for Remote. Get shared connection for RMI! If RowSet is transfred via RMI, closing the RowSet does not close the connection

Returns:
result as RowSet

isClosed

public boolean isClosed()
                 throws SQLException
isClosed

Specified by:
isClosed in interface Statement
Returns:
Throws:
SQLException
See Also:
Statement.isClosed()

isPoolable

public boolean isPoolable()
                   throws SQLException
isPoolable

Specified by:
isPoolable in interface Statement
Returns:
Throws:
SQLException
See Also:
Statement.isPoolable()

setPoolable

public void setPoolable(boolean poolable)
                 throws SQLException
setPoolable

Specified by:
setPoolable in interface Statement
Parameters:
poolable -
Throws:
SQLException
See Also:
Statement.setPoolable(boolean)

isWrapperFor

public boolean isWrapperFor(Class<?> iface)
                     throws SQLException
isWrapperFor

Specified by:
isWrapperFor in interface Wrapper
Parameters:
iface -
Returns:
Throws:
SQLException
See Also:
Wrapper.isWrapperFor(java.lang.Class)

unwrap

public <T> T unwrap(Class<T> iface)
         throws SQLException
unwrap

Specified by:
unwrap in interface Wrapper
Type Parameters:
T -
Parameters:
iface -
Returns:
Throws:
SQLException
See Also:
Wrapper.unwrap(java.lang.Class)

Compiere 3.1

Compiere® is a registered trademark of ComPiere, Inc. ©2004-2008 HumanFlash.com All rights reserved.