Class SQLRCursor

java.lang.Object
  |
  +--SQLRCursor

public class SQLRCursor
extends java.lang.Object


Field Summary
 int cursor
          cursor is used internally, it's just public to make the JNI wrapper work faster.
 
Constructor Summary
SQLRCursor(SQLRConnection con)
           
 
Method Summary
 int affectedRows()
          Returns the number of rows that were updated, inserted or deleted by the query.
 void cacheOff()
          Sets query caching off.
 void cacheToFile(java.lang.String filename)
          Columns names are converted to lower case.
 void clearBinds()
          Clear all bind variables.
 int colCount()
          Returns the number of columns in the current result set.
 void defineOutputBind(java.lang.String variable, int bufferlength)
          Define an output bind variable.
 void delete()
           
 void dontGetColumnInfo()
          Tells the server not to send any column info (names, types, sizes).
 int endOfResultSet()
          Returns 0 if part of the result set is still pending on the server and 1 if not.
 java.lang.String errorMessage()
          If a query failed and generated an error, the error message is available here.
 int executeQuery()
          Execute the query that was previously prepared and bound.
 int firstRowIndex()
          Returns the index of the first buffered row.
 java.lang.String getCacheFileName()
          Returns the name of the file containing the cached result set.
 void getColumnInfo()
          Tells the server to send column info.
 int getColumnLength(int col)
          Returns the length of the specified column.
 int getColumnLength(java.lang.String col)
          Returns the length of the specified column.
 java.lang.String getColumnName(int col)
          Returns the name of the specified column.
 java.lang.String[] getColumnNames()
          Returns a null terminated array of the column names of the current result set.
 java.lang.String getColumnType(int col)
          Returns the type of the specified column.
 java.lang.String getColumnType(java.lang.String col)
          Returns the type of the specified column.
 java.lang.String getField(int row, int col)
          Returns a pointer to the value of the specified row and column.
 java.lang.String getField(int row, java.lang.String col)
          Returns a pointer to the value of the specified row and column.
 long getFieldLength(int row, int col)
          Returns the length of the specified row and column.
 long getFieldLength(int row, java.lang.String col)
          Returns the length of the specified row and column.
 int getLongest(int col)
          Returns the length of the longest field in the specified column.
 int getLongest(java.lang.String col)
          Returns the length of the longest field in the specified column.
 void getNullsAsEmptyStrings()
          Tells the connection to return NULL fields and output bind variables as empty strings.
 void getNullsAsNulls()
          Tells the connection to return NULL fields and output bind variables as NULL's rather than as empty strings.
 java.lang.String getOutputBind(java.lang.String variable)
          Get the value stored in a previously defined output bind variable.
 int getResultSetBufferSize()
          Returns the number of result set rows that will be buffered at a time or 0 for the entire result set.
 int getResultSetId()
          Returns the internal ID of this result set.
 java.lang.String[] getRow(int row)
          Returns a null terminated array of the values of the fields in the specified row.
 long[] getRowLengths(int row)
          Returns a null terminated array of the lengths of the fields in the specified row.
 void inputBind(java.lang.String variable, double value, int precision, int scale)
          Define an input bind variable.
 void inputBind(java.lang.String variable, long value)
          Define an input bind variable.
 void inputBind(java.lang.String variable, java.lang.String value)
          Define an input bind variable.
 void inputBinds(java.lang.String[] variables, double[] values, int[] precisions, int[] scales)
          Define an array of input bind variables.
 void inputBinds(java.lang.String[] variables, long[] values)
          Define an array of input bind variables.
 void inputBinds(java.lang.String[] variables, java.lang.String[] values)
          Define an array of input bind variables.
 void lowerCaseColumnNames()
          Columns names are converted to upper case.
 void mixedCaseColumnNames()
          Sets query caching on.
 int openCachedResultSet(java.lang.String filename)
          Opens a cached result set.
 int prepareFileQuery(java.lang.String path, java.lang.String filename)
          Prepare to execute "query" with length "length".
 void prepareQuery(java.lang.String query)
          Prepare to execute "query".
 void prepareQuery(java.lang.String query, int length)
          Prepare to execute the contents of "path"/"filename".
 int resumeCachedResultSet(int id, java.lang.String filename)
          Resumes a result set previously left open using suspendSession() and continues caching the result set to "filename".
 int resumeResultSet(int id)
          Resumes a result set previously left open using suspendSession().
 int rowCount()
          Returns the number of rows in the current result set (if the result set is being stepped through, this returns the number of rows processed so far).
 int sendFileQuery(java.lang.String path, java.lang.String filename)
          Sends "query" with length "length" and gets a result set.
 int sendQuery(java.lang.String query)
          Sends "query" and gets a result set.
 int sendQuery(java.lang.String query, int length)
          Sends the query in file "path"/"filename" and gets a result set.
 void setCacheTtl(int ttl)
          Sets the time-to-live for cached result sets.
 void setResultSetBufferSize(int rows)
          Sets the number of rows of the result set to buffer at a time.
 void substitution(java.lang.String variable, double value, int precision, int scale)
          Define a substitution variable.
 void substitution(java.lang.String variable, long value)
          Define a substitution variable.
 void substitution(java.lang.String variable, java.lang.String value)
          Define a substitution variable.
 void substitutions(java.lang.String[] variables, double[] values, int[] precisions, int[] scales)
          Define an array of substitution variables.
 void substitutions(java.lang.String[] variables, long[] values)
          Define an array of substitution variables.
 void substitutions(java.lang.String[] variables, java.lang.String[] values)
          Define an array of substitution variables.
 void suspendResultSet()
          Tells the server to leave this result set open when the connection calls suspendSession() so that another connection can connect to it using resumeResultSet() after it calls resumeSession().
 int totalRows()
          Returns the total number of rows that will be returned in the result set.
 void upperCaseColumnNames()
          Columns names are returned in the same case as they are defined in the database.
 void validateBinds()
          If you are binding to any variables that might not actually be in your query, call this to ensure that the database won't try to bind them unless they really are in the query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cursor

public int cursor
cursor is used internally, it's just public to make the JNI wrapper work faster.
Constructor Detail

SQLRCursor

public SQLRCursor(SQLRConnection con)
Method Detail

delete

public void delete()

setResultSetBufferSize

public void setResultSetBufferSize(int rows)
Sets the number of rows of the result set to buffer at a time. 0 (the default) means buffer the entire result set.

getResultSetBufferSize

public int getResultSetBufferSize()
Returns the number of result set rows that will be buffered at a time or 0 for the entire result set.

dontGetColumnInfo

public void dontGetColumnInfo()
Tells the server not to send any column info (names, types, sizes). If you don't need that info, you should call this method to improve performance.

getColumnInfo

public void getColumnInfo()
Tells the server to send column info.

mixedCaseColumnNames

public void mixedCaseColumnNames()
Sets query caching on. Future queries will be cached to the file "filename". A default time-to-live of 10 minutes is also set. Note that once cacheToFile() is called, the result sets of all future queries will be cached to that file until another call to cacheToFile() changes which file to cache to or a call to cacheOff() turns off caching.

upperCaseColumnNames

public void upperCaseColumnNames()
Columns names are returned in the same case as they are defined in the database. This is the default.

lowerCaseColumnNames

public void lowerCaseColumnNames()
Columns names are converted to upper case.

cacheToFile

public void cacheToFile(java.lang.String filename)
Columns names are converted to lower case.

setCacheTtl

public void setCacheTtl(int ttl)
Sets the time-to-live for cached result sets. The sqlr-cachemanger will remove each cached result set "ttl" seconds after it's created, provided it's scanning the directory containing the cache files.

getCacheFileName

public java.lang.String getCacheFileName()
Returns the name of the file containing the cached result set.

cacheOff

public void cacheOff()
Sets query caching off.

sendQuery

public int sendQuery(java.lang.String query)
Sends "query" and gets a result set.

sendQuery

public int sendQuery(java.lang.String query,
                     int length)
Sends the query in file "path"/"filename" and gets a result set.

sendFileQuery

public int sendFileQuery(java.lang.String path,
                         java.lang.String filename)
Sends "query" with length "length" and gets a result set. This method must be used if the query contains binary data.

prepareQuery

public void prepareQuery(java.lang.String query)
Prepare to execute "query".

prepareQuery

public void prepareQuery(java.lang.String query,
                         int length)
Prepare to execute the contents of "path"/"filename". Returns 0 if the file couldn't be opened.

prepareFileQuery

public int prepareFileQuery(java.lang.String path,
                            java.lang.String filename)
Prepare to execute "query" with length "length". This method must be used if the query contains binary data.

clearBinds

public void clearBinds()
Clear all bind variables.

substitution

public void substitution(java.lang.String variable,
                         java.lang.String value)
Define a substitution variable.

substitution

public void substitution(java.lang.String variable,
                         long value)
Define a substitution variable.

substitution

public void substitution(java.lang.String variable,
                         double value,
                         int precision,
                         int scale)
Define a substitution variable.

inputBind

public void inputBind(java.lang.String variable,
                      java.lang.String value)
Define an input bind variable.

inputBind

public void inputBind(java.lang.String variable,
                      long value)
Define an input bind variable.

inputBind

public void inputBind(java.lang.String variable,
                      double value,
                      int precision,
                      int scale)
Define an input bind variable.

defineOutputBind

public void defineOutputBind(java.lang.String variable,
                             int bufferlength)
Define an output bind variable.

substitutions

public void substitutions(java.lang.String[] variables,
                          java.lang.String[] values)
Define an array of substitution variables.

substitutions

public void substitutions(java.lang.String[] variables,
                          long[] values)
Define an array of substitution variables.

substitutions

public void substitutions(java.lang.String[] variables,
                          double[] values,
                          int[] precisions,
                          int[] scales)
Define an array of substitution variables.

inputBinds

public void inputBinds(java.lang.String[] variables,
                       java.lang.String[] values)
Define an array of input bind variables.

inputBinds

public void inputBinds(java.lang.String[] variables,
                       long[] values)
Define an array of input bind variables.

inputBinds

public void inputBinds(java.lang.String[] variables,
                       double[] values,
                       int[] precisions,
                       int[] scales)
Define an array of input bind variables.

validateBinds

public void validateBinds()
If you are binding to any variables that might not actually be in your query, call this to ensure that the database won't try to bind them unless they really are in the query. There is a performance penalty for calling this method.

executeQuery

public int executeQuery()
Execute the query that was previously prepared and bound.

getOutputBind

public java.lang.String getOutputBind(java.lang.String variable)
Get the value stored in a previously defined output bind variable.

openCachedResultSet

public int openCachedResultSet(java.lang.String filename)
Opens a cached result set. Returns 1 on success and 0 on failure.

colCount

public int colCount()
Returns the number of columns in the current result set.

rowCount

public int rowCount()
Returns the number of rows in the current result set (if the result set is being stepped through, this returns the number of rows processed so far).

totalRows

public int totalRows()
Returns the total number of rows that will be returned in the result set. Not all databases support this call. Don't use it for applications which are designed to be portable across databases. -1 is returned by databases which don't support this option.

affectedRows

public int affectedRows()
Returns the number of rows that were updated, inserted or deleted by the query. Not all databases support this call. Don't use it for applications which are designed to be portable across databases. -1 is returned by databases which don't support this option.

firstRowIndex

public int firstRowIndex()
Returns the index of the first buffered row. This is useful when buffering only part of the result set at a time.

endOfResultSet

public int endOfResultSet()
Returns 0 if part of the result set is still pending on the server and 1 if not. This method can only return 0 if setResultSetBufferSize() has been called with a parameter other than 0.

errorMessage

public java.lang.String errorMessage()
If a query failed and generated an error, the error message is available here. If the query succeeded then this method returns a NULL.

getNullsAsEmptyStrings

public void getNullsAsEmptyStrings()
Tells the connection to return NULL fields and output bind variables as empty strings. This is the default.

getNullsAsNulls

public void getNullsAsNulls()
Tells the connection to return NULL fields and output bind variables as NULL's rather than as empty strings.

getField

public java.lang.String getField(int row,
                                 int col)
Returns a pointer to the value of the specified row and column.

getField

public java.lang.String getField(int row,
                                 java.lang.String col)
Returns a pointer to the value of the specified row and column.

getFieldLength

public long getFieldLength(int row,
                           int col)
Returns the length of the specified row and column.

getFieldLength

public long getFieldLength(int row,
                           java.lang.String col)
Returns the length of the specified row and column.

getRow

public java.lang.String[] getRow(int row)
Returns a null terminated array of the values of the fields in the specified row.

getRowLengths

public long[] getRowLengths(int row)
Returns a null terminated array of the lengths of the fields in the specified row.

getColumnNames

public java.lang.String[] getColumnNames()
Returns a null terminated array of the column names of the current result set.

getColumnName

public java.lang.String getColumnName(int col)
Returns the name of the specified column.

getColumnType

public java.lang.String getColumnType(int col)
Returns the type of the specified column.

getColumnType

public java.lang.String getColumnType(java.lang.String col)
Returns the type of the specified column.

getColumnLength

public int getColumnLength(int col)
Returns the length of the specified column.

getColumnLength

public int getColumnLength(java.lang.String col)
Returns the length of the specified column.

getLongest

public int getLongest(int col)
Returns the length of the longest field in the specified column.

getLongest

public int getLongest(java.lang.String col)
Returns the length of the longest field in the specified column.

getResultSetId

public int getResultSetId()
Returns the internal ID of this result set. This parameter may be passed to another cursor for use in the resumeResultSet() method.

suspendResultSet

public void suspendResultSet()
Tells the server to leave this result set open when the connection calls suspendSession() so that another connection can connect to it using resumeResultSet() after it calls resumeSession().

resumeResultSet

public int resumeResultSet(int id)
Resumes a result set previously left open using suspendSession(). Returns 1 on success and 0 on failure.

resumeCachedResultSet

public int resumeCachedResultSet(int id,
                                 java.lang.String filename)
Resumes a result set previously left open using suspendSession() and continues caching the result set to "filename". Returns 1 on success and 0 on failure.