org.sqlite.jdbc
Class JdbcStatement

java.lang.Object
  extended by org.sqlite.jdbc.JdbcStatement
All Implemented Interfaces:
java.sql.Statement
Direct Known Subclasses:
JdbcPreparedStatement

public class JdbcStatement
extends java.lang.Object
implements java.sql.Statement


Field Summary
protected  int cntUpdate
          last update count.
protected  int currentRet
          current of result
protected  Database db
          parent Database object.
protected  java.util.List<java.lang.Object> results
          results of multiple statement
protected  java.sql.ResultSet rs
          current ResultSet 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
JdbcStatement(Database db, java.sql.Connection owner)
           
 
Method Summary
 void addBatch(java.lang.String sql)
           
 void cancel()
          invoke org.sqlite.Database#interrupt() method.
 void clearBatch()
           
 void clearWarnings()
          nothing.
 void close()
           
 void close(java.sql.ResultSet drs)
          ResultSetを切り離してStatementをcloseする。
protected  void closeResultSets()
           
 void detach(java.sql.ResultSet drs)
          Statement#close()時にResultSetも一緒にcloseされないようにResultSetを切り離す。
protected  boolean execute(Statement stmt)
           
 boolean execute(java.lang.String sql)
           
 boolean execute(java.lang.String sql, int autoGeneratedKeys)
           
 boolean execute(java.lang.String sql, int[] columnIndexes)
          Not supporetd yet.
 boolean execute(java.lang.String sql, java.lang.String[] columnNames)
          Not supporetd yet.
 int[] executeBatch()
           
 java.sql.ResultSet executeQuery(java.lang.String sql)
           
 int executeUpdate(java.lang.String sql)
           
 int executeUpdate(java.lang.String sql, int autoGeneratedKeys)
           
 int executeUpdate(java.lang.String sql, int[] columnIndexes)
          Not supporetd yet.
 int executeUpdate(java.lang.String sql, java.lang.String[] columnNames)
          Not supporetd yet.
protected  void finalize()
           
 java.sql.Connection getConnection()
           
 int getFetchDirection()
          It always returns FETCH_FORWARD.
 int getFetchSize()
          It always returns 0.
 java.sql.ResultSet getGeneratedKeys()
          invoke executeQuery("SELECT last_insert_rowid()") method.
 long getLastInsertRowId()
          invoke org.sqlite.Database#lastInsertRowId() method.
 int getMaxFieldSize()
          It always returns 0.
 int getMaxRows()
          It always returns 0.
 boolean getMoreResults()
          invoke getMoreResults(CLOSE_CURRENT_RESULT) method.
 boolean getMoreResults(int current)
          Moves to this Statement object's next result, deals with any current ResultSet object(s) according to the instructions specified by the given flag, and returns true if the next result is a ResultSet object.
 int getQueryTimeout()
          invoke org.sqlite.Database#getBusyTimeout() method and divide by 1000.
 java.sql.ResultSet getResultSet()
           
 int getResultSetConcurrency()
          It always returns CONCUR_READ_ONLY.
 int getResultSetHoldability()
          It always returns CLOSE_CURSORS_AT_COMMIT.
 int getResultSetType()
          It always returns TYPE_FORWARD_ONLY.
 int getUpdateCount()
           
 java.sql.SQLWarning getWarnings()
          It always returns null.
 boolean isClosed()
           
 void setCursorName(java.lang.String name)
          Not supporetd yet.
 void setEscapeProcessing(boolean enable)
          Not supporetd yet.
 void setFetchDirection(int direction)
          Supported fetch direction is FETCH_FORWARD only.
 void setFetchSize(int rows)
          Not supporetd yet.
 void setMaxFieldSize(int max)
          Not supporetd yet.
 void setMaxRows(int max)
          Not supporetd yet.
 void setQueryTimeout(int seconds)
          multiply the seconds by 1000 and invoke org.sqlite.Database#setBusyTimeout(int) method.
static void validateAutoGeneretedKeys(int autoGeneratedKeys)
           
static void validateCurrentResult(int current)
           
protected  void validateStatementOpen()
           
protected  void validateStaticSQL(Statement stmt)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

db

protected Database db
parent Database object.


results

protected java.util.List<java.lang.Object> results
results of multiple statement


currentRet

protected int currentRet
current of result


rs

protected java.sql.ResultSet rs
current ResultSet object.


cntUpdate

protected int cntUpdate
last update count.

Constructor Detail

JdbcStatement

public JdbcStatement(Database db,
                     java.sql.Connection owner)
Method Detail

executeQuery

public java.sql.ResultSet executeQuery(java.lang.String sql)
                                throws java.sql.SQLException
Specified by:
executeQuery in interface java.sql.Statement
Throws:
java.sql.SQLException

executeUpdate

public int executeUpdate(java.lang.String sql)
                  throws java.sql.SQLException
Specified by:
executeUpdate in interface java.sql.Statement
Throws:
java.sql.SQLException

close

public void close()
           throws java.sql.SQLException
Specified by:
close in interface java.sql.Statement
Throws:
java.sql.SQLException

getMaxFieldSize

public int getMaxFieldSize()
                    throws java.sql.SQLException
It always returns 0.

Specified by:
getMaxFieldSize in interface java.sql.Statement
Returns:
0
Throws:
java.sql.SQLException

setMaxFieldSize

public void setMaxFieldSize(int max)
                     throws java.sql.SQLException
Not supporetd yet.

Specified by:
setMaxFieldSize in interface java.sql.Statement
Parameters:
max - ignored
Throws:
java.lang.UnsupportedOperationException
java.sql.SQLException

getMaxRows

public int getMaxRows()
               throws java.sql.SQLException
It always returns 0.

Specified by:
getMaxRows in interface java.sql.Statement
Returns:
0
Throws:
java.sql.SQLException

setMaxRows

public void setMaxRows(int max)
                throws java.sql.SQLException
Not supporetd yet.

Specified by:
setMaxRows in interface java.sql.Statement
Parameters:
max - ignored
Throws:
java.lang.UnsupportedOperationException
java.sql.SQLException

setEscapeProcessing

public void setEscapeProcessing(boolean enable)
                         throws java.sql.SQLException
Not supporetd yet.

Specified by:
setEscapeProcessing in interface java.sql.Statement
Parameters:
enable - ignored
Throws:
java.lang.UnsupportedOperationException
java.sql.SQLException

getQueryTimeout

public int getQueryTimeout()
                    throws java.sql.SQLException
invoke org.sqlite.Database#getBusyTimeout() method and divide by 1000.

Specified by:
getQueryTimeout in interface java.sql.Statement
Returns:
Throws:
java.sql.SQLException
See Also:
Database.getBusyTimeout()

setQueryTimeout

public void setQueryTimeout(int seconds)
                     throws java.sql.SQLException
multiply the seconds by 1000 and invoke org.sqlite.Database#setBusyTimeout(int) method.

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

cancel

public void cancel()
            throws java.sql.SQLException
invoke org.sqlite.Database#interrupt() method.

Specified by:
cancel in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Database.interrupt()

getWarnings

public java.sql.SQLWarning getWarnings()
                                throws java.sql.SQLException
It always returns null.

Specified by:
getWarnings in interface java.sql.Statement
Returns:
null
Throws:
java.sql.SQLException

clearWarnings

public void clearWarnings()
                   throws java.sql.SQLException
nothing.

Specified by:
clearWarnings in interface java.sql.Statement
Throws:
java.sql.SQLException

setCursorName

public void setCursorName(java.lang.String name)
                   throws java.sql.SQLException
Not supporetd yet.

Specified by:
setCursorName in interface java.sql.Statement
Throws:
java.lang.UnsupportedOperationException
java.sql.SQLException

execute

public boolean execute(java.lang.String sql)
                throws java.sql.SQLException
Specified by:
execute in interface java.sql.Statement
Throws:
java.sql.SQLException

getResultSet

public java.sql.ResultSet getResultSet()
                                throws java.sql.SQLException
Specified by:
getResultSet in interface java.sql.Statement
Throws:
java.sql.SQLException

getUpdateCount

public int getUpdateCount()
                   throws java.sql.SQLException
Specified by:
getUpdateCount in interface java.sql.Statement
Throws:
java.sql.SQLException

getMoreResults

public boolean getMoreResults()
                       throws java.sql.SQLException
invoke getMoreResults(CLOSE_CURRENT_RESULT) method.

Specified by:
getMoreResults in interface java.sql.Statement
Returns:
true if the next result is a ResultSet object; false if it is an update count or there are no more results
Throws:
java.sql.SQLException
See Also:
getMoreResults(int)

setFetchDirection

public void setFetchDirection(int direction)
                       throws java.sql.SQLException
Supported fetch direction is FETCH_FORWARD only.

Specified by:
setFetchDirection in interface java.sql.Statement
Parameters:
direction -
Throws:
java.sql.SQLException

getFetchDirection

public int getFetchDirection()
                      throws java.sql.SQLException
It always returns FETCH_FORWARD.

Specified by:
getFetchDirection in interface java.sql.Statement
Returns:
java.sql.ResultSet.FETCH_FORWARD
Throws:
java.sql.SQLException

setFetchSize

public void setFetchSize(int rows)
                  throws java.sql.SQLException
Not supporetd yet.

Specified by:
setFetchSize in interface java.sql.Statement
Parameters:
rows - ignored
Throws:
java.lang.UnsupportedOperationException
java.sql.SQLException

getFetchSize

public int getFetchSize()
                 throws java.sql.SQLException
It always returns 0.

Specified by:
getFetchSize in interface java.sql.Statement
Returns:
0
Throws:
java.sql.SQLException

getResultSetConcurrency

public int getResultSetConcurrency()
                            throws java.sql.SQLException
It always returns CONCUR_READ_ONLY.

Specified by:
getResultSetConcurrency in interface java.sql.Statement
Returns:
java.sql.ResultSet.CONCUR_READ_ONLY
Throws:
java.sql.SQLException

getResultSetType

public int getResultSetType()
                     throws java.sql.SQLException
It always returns TYPE_FORWARD_ONLY.

Specified by:
getResultSetType in interface java.sql.Statement
Returns:
java.sql.ResultSet.TYPE_FORWARD_ONLY
Throws:
java.sql.SQLException

addBatch

public void addBatch(java.lang.String sql)
              throws java.sql.SQLException
Specified by:
addBatch in interface java.sql.Statement
Throws:
java.sql.SQLException

clearBatch

public void clearBatch()
                throws java.sql.SQLException
Specified by:
clearBatch in interface java.sql.Statement
Throws:
java.sql.SQLException

executeBatch

public int[] executeBatch()
                   throws java.sql.SQLException
Specified by:
executeBatch in interface java.sql.Statement
Throws:
java.sql.SQLException

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Specified by:
getConnection in interface java.sql.Statement
Throws:
java.sql.SQLException

getMoreResults

public boolean getMoreResults(int current)
                       throws java.sql.SQLException
Moves to this Statement object's next result, deals with any current ResultSet object(s) according to the instructions specified by the given flag, and returns true if the next result is a ResultSet object.

Specified by:
getMoreResults in interface java.sql.Statement
Parameters:
current - Statement.CLOSE_CURRENT_RESULT or Statement.KEEP_CURRENT_RESULT or Statement.CLOSE_ALL_RESULTS
Returns:
true if the next result is a ResultSet object; false if it is an update count or there are no more results
Throws:
java.sql.SQLException

getGeneratedKeys

public java.sql.ResultSet getGeneratedKeys()
                                    throws java.sql.SQLException
invoke executeQuery("SELECT last_insert_rowid()") method.

Specified by:
getGeneratedKeys in interface java.sql.Statement
Returns:
Throws:
java.sql.SQLException
See Also:
Last Insert Rowid

executeUpdate

public int executeUpdate(java.lang.String sql,
                         int autoGeneratedKeys)
                  throws java.sql.SQLException
Specified by:
executeUpdate in interface java.sql.Statement
Parameters:
sql - SQL to be evaluated
autoGeneratedKeys - ignored
Returns:
Throws:
java.sql.SQLException

executeUpdate

public int executeUpdate(java.lang.String sql,
                         int[] columnIndexes)
                  throws java.sql.SQLException
Not supporetd yet.

Specified by:
executeUpdate in interface java.sql.Statement
Parameters:
sql - SQL to be evaluated
columnIndexes - ignored
Returns:
Throws:
java.lang.UnsupportedOperationException
java.sql.SQLException

executeUpdate

public int executeUpdate(java.lang.String sql,
                         java.lang.String[] columnNames)
                  throws java.sql.SQLException
Not supporetd yet.

Specified by:
executeUpdate in interface java.sql.Statement
Parameters:
sql - SQL to be evaluated
columnNames - ignored
Returns:
Throws:
java.lang.UnsupportedOperationException
java.sql.SQLException

execute

public boolean execute(java.lang.String sql,
                       int autoGeneratedKeys)
                throws java.sql.SQLException
Specified by:
execute in interface java.sql.Statement
Parameters:
sql - SQL to be evaluated
autoGeneratedKeys - ignored
Returns:
Throws:
java.sql.SQLException

execute

public boolean execute(java.lang.String sql,
                       int[] columnIndexes)
                throws java.sql.SQLException
Not supporetd yet.

Specified by:
execute in interface java.sql.Statement
Parameters:
sql - SQL to be evaluated
columnIndexes - ignored
Returns:
Throws:
java.lang.UnsupportedOperationException
java.sql.SQLException

execute

public boolean execute(java.lang.String sql,
                       java.lang.String[] columnNames)
                throws java.sql.SQLException
Not supporetd yet.

Specified by:
execute in interface java.sql.Statement
Parameters:
sql - SQL to be evaluated
columnNames - ignored
Returns:
Throws:
java.lang.UnsupportedOperationException
java.sql.SQLException

getResultSetHoldability

public int getResultSetHoldability()
                            throws java.sql.SQLException
It always returns CLOSE_CURSORS_AT_COMMIT.

Specified by:
getResultSetHoldability in interface java.sql.Statement
Returns:
java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT
Throws:
java.sql.SQLException

isClosed

public boolean isClosed()
                 throws java.sql.SQLException
Throws:
java.sql.SQLException

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

validateStatementOpen

protected void validateStatementOpen()
                              throws java.sql.SQLException
Throws:
java.sql.SQLException

validateStaticSQL

protected void validateStaticSQL(Statement stmt)
                          throws java.sql.SQLException
Throws:
java.sql.SQLException

validateAutoGeneretedKeys

public static void validateAutoGeneretedKeys(int autoGeneratedKeys)
                                      throws java.sql.SQLException
Throws:
java.sql.SQLException

validateCurrentResult

public static void validateCurrentResult(int current)
                                  throws java.sql.SQLException
Throws:
java.sql.SQLException

detach

public void detach(java.sql.ResultSet drs)
            throws java.sql.SQLException
Statement#close()時にResultSetも一緒にcloseされないようにResultSetを切り離す。

Parameters:
drs - ResultSet that wants to be detached
Throws:
java.sql.SQLException

close

public void close(java.sql.ResultSet drs)
           throws java.sql.SQLException
ResultSetを切り離してStatementをcloseする。

Parameters:
drs - ResultSet that wants to be detached
Throws:
java.sql.SQLException

getLastInsertRowId

public long getLastInsertRowId()
                        throws java.sql.SQLException
invoke org.sqlite.Database#lastInsertRowId() method.

Returns:
Throws:
java.sql.SQLException
See Also:
Database.lastInsertRowId()

execute

protected boolean execute(Statement stmt)
                   throws java.sql.SQLException
Throws:
java.sql.SQLException

closeResultSets

protected void closeResultSets()
                        throws java.sql.SQLException
Throws:
java.sql.SQLException