Package com.firstworks.sqlrelay
Class SQLRCursor
java.lang.Object
com.firstworks.sqlrelay.SQLRCursor
-
Field Summary
Modifier and TypeFieldDescriptionlong
cursor and connection are used internally, they're just public to make the JNI wrapper work faster. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
Returns the number of rows that were updated, inserted or deleted by the query.void
cacheOff()
Sets query caching off.void
cacheToFile
(String filename) Sets query caching on.void
Clear all bind variables.void
Closes the current result set, if one is open.int
colCount()
Returns the number of columns in the current result set.short
Parses the previously prepared query, counts the number of bind variables defined in it and returns that number.void
defineOutputBindBlob
(String variable) Define an output bind variable.void
defineOutputBindClob
(String variable) Define an output bind variable.void
defineOutputBindCursor
(String variable) Define an output bind variable.void
defineOutputBindDouble
(String variable) Define a double precision floating point output bind variable.void
defineOutputBindInteger
(String variable) Define an integer output bind variable.void
defineOutputBindString
(String variable, int bufferlength) Define a string output bind variable.void
delete()
void
Tells the server not to send any column info (names, types, sizes).boolean
Returns 0 if part of the result set is still pending on the server and 1 if not.If a query failed and generated an error, the error message is available here.long
If a query failed and generated an error, the error number is available here.boolean
Execute the query that was previously prepared and bound.boolean
Fetch from a cursor that was returned as an output bind variable.long
Returns the index of the first buffered row.Returns the name of the file containing the cached result set.void
Tells the server to send column info.boolean
getColumnIsAutoIncrement
(int col) Returns true if the specified column auto-increments and false otherwise.boolean
Returns true if the specified column auto-increments and false otherwise.boolean
getColumnIsBinary
(int col) Returns true if the specified column contains binary data and false otherwise.boolean
getColumnIsBinary
(String col) Returns true if the specified column contains binary data and false otherwise.boolean
getColumnIsNullable
(int col) Returns true if the specified column can contain nulls and false otherwise.boolean
Returns true if the specified column can contain nulls and false otherwise.boolean
getColumnIsPartOfKey
(int col) Returns true if the specified column is part of a composite key and false otherwise.boolean
Returns true if the specified column is part of a composite key and false otherwise.boolean
getColumnIsPrimaryKey
(int col) Returns true if the specified column is a primary key and false otherwise.boolean
Returns true if the specified column is a primary key and false otherwise.boolean
getColumnIsUnique
(int col) Returns true if the specified column is unique and false otherwise.boolean
getColumnIsUnique
(String col) Returns true if the specified column is unique and false otherwise.boolean
getColumnIsUnsigned
(int col) Returns true if the specified column is an unsigned number and false otherwise.boolean
Returns true if the specified column is an unsigned number and false otherwise.boolean
getColumnIsZeroFilled
(int col) Returns true if the specified column was created with the zero-fill flag and false otherwise.boolean
Returns true if the specified column was created with the zero-fill flag and false otherwise.int
getColumnLength
(int col) Returns the length of the specified column.int
getColumnLength
(String col) Returns the length of the specified column.boolean
getColumnList
(String table, String wild) Sends a query that returns a list of columns in the table specified by the "table" parameter matching "wild".boolean
getColumnListWithFormat
(String table, String wild, int listformat) getColumnName
(int col) Returns the name of the specified column.String[]
Returns a null terminated array of the column names of the current result set.long
getColumnPrecision
(int col) Returns the precision of the specified column.long
getColumnPrecision
(String col) Returns the precision of the specified column.long
getColumnScale
(int col) Returns the scale of the specified column.long
getColumnScale
(String col) Returns the scale of the specified column.getColumnType
(int col) Returns the type of the specified column.getColumnType
(String col) Returns the type of the specified column.boolean
getDatabaseList
(String wild) Sends a query that returns a list of databases/schemas matching "wild".boolean
getDatabaseListWithFormat
(String wild, int listformat) getField
(long row, int col) Returns a pointer to the value of the specified row and column.Returns a pointer to the value of the specified row and column.byte[]
getFieldAsByteArray
(long row, int col) Returns a pointer to the value of the specified row and column.byte[]
getFieldAsByteArray
(long row, String col) Returns the length of the specified row and column.double
getFieldAsDouble
(long row, int col) Returns the specified field as a double floating point numberdouble
getFieldAsDouble
(long row, String col) Returns the specified field as a double floating point numberlong
getFieldAsInteger
(long row, int col) Returns the specified field as a long integerlong
getFieldAsInteger
(long row, String col) Returns the specified field as a long integerlong
getFieldLength
(long row, int col) Returns the length of the specified row and column.long
getFieldLength
(long row, 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
(String col) Returns the length of the longest field in the specified column.void
Tells the connection to return NULL fields and output bind variables as empty strings.void
Tells the connection to return NULL fields and output bind variables as NULL's rather than as empty strings.byte[]
getOutputBindAsByteArray
(String variable) Get the length of the value stored in a previously defined output bind variable.byte[]
getOutputBindBlob
(String variable) Get the value stored in a previously defined output bind variable.getOutputBindClob
(String variable) Get the value stored in a previously defined output bind variable.getOutputBindCursor
(String variable) Get the cursor associated with a previously defined output bind variable.double
getOutputBindDouble
(String variable) Get the value stored in a previously defined output bind variable as a double precision floating point number.long
getOutputBindInteger
(String variable) Get the value stored in a previously defined output bind variable as a long integer.long
getOutputBindLength
(String variable) Get the length of the value stored in a previously defined output bind variable.getOutputBindString
(String variable) Get the value stored in a previously defined output bind variable.long
Returns the number of result set rows that will be buffered at a time or 0 for the entire result set.short
Returns the internal ID of this result set.String[]
getRow
(long row) Returns a null terminated array of the values of the fields in the specified row.long[]
getRowLengths
(long row) Returns a null terminated array of the lengths of the fields in the specified row.boolean
getSchemaListWithFormat
(String wild, int listformat) boolean
getTableList
(String wild) Sends a query that returns a list of tables matching "wild".boolean
getTableListWithFormat
(String wild, int listformat, int objecttypes) void
Define an input bind variable.void
Define an input bind variable.void
Define an input bind variable.void
Define an input bind variable.void
inputBindBlob
(String variable, byte[] value, long size) Define an input bind variable.void
inputBindClob
(String variable, String value, long size) Define an input bind variable.void
inputBinds
(String[] variables, double[] values, int[] precisions, int[] scales) Define an array of input bind variables.void
inputBinds
(String[] variables, long[] values) Define an array of input bind variables.void
inputBinds
(String[] variables, String[] values) Define an array of input bind variables.void
Columns names are converted to lower case.void
Columns names are returned in the same case as they are defined in the database.boolean
openCachedResultSet
(String filename) Opens a cached result set.boolean
prepareFileQuery
(String path, String filename) Prepare to execute "query" with length "length".void
prepareQuery
(String query) Prepare to execute "query".void
prepareQuery
(String query, int length) Prepare to execute the contents of "path"/"filename".boolean
resumeCachedResultSet
(short id, String filename) Resumes a result set previously left open using suspendSession() and continues caching the result set to "filename".boolean
resumeResultSet
(short id) Resumes a result set previously left open using suspendSession().long
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).boolean
sendFileQuery
(String path, String filename) Sends "query" with length "length" and gets a result set.boolean
Sends "query" and gets a result set.boolean
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
(long rows) Sets the number of rows of the result set to buffer at a time.void
substitution
(String variable, double value, int precision, int scale) Define a substitution variable.void
substitution
(String variable, long value) Define a substitution variable.void
substitution
(String variable, String value) Define a substitution variable.void
substitutions
(String[] variables, double[] values, int[] precisions, int[] scales) Define an array of substitution variables.void
substitutions
(String[] variables, long[] values) Define an array of substitution variables.void
substitutions
(String[] variables, String[] values) Define an array of substitution variables.void
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().long
Returns the total number of rows that will be returned in the result set.void
Columns names are converted to upper case.void
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.boolean
Returns true if "variable" was a valid bind variable of the query
-
Field Details
-
cursor
public long cursorcursor and connection are used internally, they're just public to make the JNI wrapper work faster. -
connection
-
-
Constructor Details
-
SQLRCursor
-
-
Method Details
-
delete
public void delete() -
setResultSetBufferSize
public void setResultSetBufferSize(long 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 long 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()Columns names are returned in the same case as they are defined in the database. This is the default. -
upperCaseColumnNames
public void upperCaseColumnNames()Columns names are converted to upper case. -
lowerCaseColumnNames
public void lowerCaseColumnNames()Columns names are converted to lower case. -
cacheToFile
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. -
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
Returns the name of the file containing the cached result set. -
cacheOff
public void cacheOff()Sets query caching off. -
getDatabaseList
Sends a query that returns a list of databases/schemas matching "wild". If wild is empty or NULL then a list of all databases/schemas will be returned. -
getTableList
Sends a query that returns a list of tables matching "wild". If wild is empty or NULL then a list of all tables will be returned. -
getColumnList
Sends a query that returns a list of columns in the table specified by the "table" parameter matching "wild". If wild is empty or NULL then a list of all columns will be returned. -
sendQuery
Sends "query" and gets a result set. -
sendQuery
Sends the query in file "path"/"filename" and gets a result set. -
sendFileQuery
Sends "query" with length "length" and gets a result set. This method must be used if the query contains binary data. -
prepareQuery
Prepare to execute "query". -
prepareQuery
Prepare to execute the contents of "path"/"filename". Returns 0 if the file couldn't be opened. -
prepareFileQuery
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
Define a substitution variable. -
substitution
Define a substitution variable. -
substitution
Define a substitution variable. -
countBindVariables
public short countBindVariables()Parses the previously prepared query, counts the number of bind variables defined in it and returns that number. -
inputBind
Define an input bind variable. -
inputBind
Define an input bind variable. -
inputBind
Define an input bind variable. -
inputBind
Define an input bind variable. (If you don't have the precision and scale then they may both be set to 0. However in that case you may get unexpected rounding behavior if the server is faking binds.) -
inputBindBlob
Define an input bind variable. -
inputBindClob
Define an input bind variable. -
defineOutputBindString
Define a string output bind variable. -
defineOutputBindInteger
Define an integer output bind variable. -
defineOutputBindDouble
Define a double precision floating point output bind variable. -
defineOutputBindBlob
Define an output bind variable. -
defineOutputBindClob
Define an output bind variable. -
defineOutputBindCursor
Define an output bind variable. -
substitutions
Define an array of substitution variables. -
substitutions
Define an array of substitution variables. -
substitutions
Define an array of substitution variables. -
inputBinds
Define an array of input bind variables. -
inputBinds
Define an array of input bind variables. -
inputBinds
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. -
validBind
Returns true if "variable" was a valid bind variable of the query -
executeQuery
public boolean executeQuery()Execute the query that was previously prepared and bound. -
fetchFromBindCursor
public boolean fetchFromBindCursor()Fetch from a cursor that was returned as an output bind variable. -
getOutputBindString
Get the value stored in a previously defined output bind variable. -
getOutputBindBlob
Get the value stored in a previously defined output bind variable. -
getOutputBindClob
Get the value stored in a previously defined output bind variable. -
getOutputBindAsByteArray
Get the length of the value stored in a previously defined output bind variable. -
getOutputBindInteger
Get the value stored in a previously defined output bind variable as a long integer. -
getOutputBindDouble
Get the value stored in a previously defined output bind variable as a double precision floating point number. -
getOutputBindLength
Get the length of the value stored in a previously defined output bind variable. -
getOutputBindCursor
Get the cursor associated with a previously defined output bind variable. -
openCachedResultSet
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 long 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 long 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 long 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 long 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 boolean 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
If a query failed and generated an error, the error message is available here. If the query succeeded then this method returns NULL. -
errorNumber
public long errorNumber()If a query failed and generated an error, the error number is available here. If there is no error then this method returns 0. -
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
Returns a pointer to the value of the specified row and column. -
getField
Returns a pointer to the value of the specified row and column. -
getFieldAsInteger
public long getFieldAsInteger(long row, int col) Returns the specified field as a long integer -
getFieldAsInteger
Returns the specified field as a long integer -
getFieldAsDouble
public double getFieldAsDouble(long row, int col) Returns the specified field as a double floating point number -
getFieldAsDouble
Returns the specified field as a double floating point number -
getFieldAsByteArray
public byte[] getFieldAsByteArray(long row, int col) Returns a pointer to the value of the specified row and column. -
getFieldAsByteArray
Returns the length of the specified row and column. -
getFieldLength
public long getFieldLength(long row, int col) Returns the length of the specified row and column. -
getFieldLength
Returns the length of the specified row and column. -
getRow
Returns a null terminated array of the values of the fields in the specified row. -
getRowLengths
public long[] getRowLengths(long row) Returns a null terminated array of the lengths of the fields in the specified row. -
getColumnNames
Returns a null terminated array of the column names of the current result set. -
getColumnName
Returns the name of the specified column. -
getColumnType
Returns the type of the specified column. -
getColumnType
Returns the type of the specified column. -
getColumnPrecision
public long getColumnPrecision(int col) Returns the precision of the specified column. Precision is the total number of digits in a number. eg: 123.45 has a precision of 5. For non-numeric types, it's the number of characters in the string. -
getColumnPrecision
Returns the precision of the specified column. Precision is the total number of digits in a number. eg: 123.45 has a precision of 5. For non-numeric types, it's the number of characters in the string. -
getColumnScale
public long getColumnScale(int col) Returns the scale of the specified column. Scale is the total number of digits to the right of the decimal point in a number. eg: 123.45 has a scale of 2. -
getColumnScale
Returns the scale of the specified column. Scale is the total number of digits to the right of the decimal point in a number. eg: 123.45 has a scale of 2. -
getColumnIsNullable
public boolean getColumnIsNullable(int col) Returns true if the specified column can contain nulls and false otherwise. -
getColumnIsNullable
Returns true if the specified column can contain nulls and false otherwise. -
getColumnIsPrimaryKey
public boolean getColumnIsPrimaryKey(int col) Returns true if the specified column is a primary key and false otherwise. -
getColumnIsPrimaryKey
Returns true if the specified column is a primary key and false otherwise. -
getColumnIsUnique
public boolean getColumnIsUnique(int col) Returns true if the specified column is unique and false otherwise. -
getColumnIsUnique
Returns true if the specified column is unique and false otherwise. -
getColumnIsPartOfKey
public boolean getColumnIsPartOfKey(int col) Returns true if the specified column is part of a composite key and false otherwise. -
getColumnIsPartOfKey
Returns true if the specified column is part of a composite key and false otherwise. -
getColumnIsUnsigned
public boolean getColumnIsUnsigned(int col) Returns true if the specified column is an unsigned number and false otherwise. -
getColumnIsUnsigned
Returns true if the specified column is an unsigned number and false otherwise. -
getColumnIsZeroFilled
public boolean getColumnIsZeroFilled(int col) Returns true if the specified column was created with the zero-fill flag and false otherwise. -
getColumnIsZeroFilled
Returns true if the specified column was created with the zero-fill flag and false otherwise. -
getColumnIsBinary
public boolean getColumnIsBinary(int col) Returns true if the specified column contains binary data and false otherwise. -
getColumnIsBinary
Returns true if the specified column contains binary data and false otherwise. -
getColumnIsAutoIncrement
public boolean getColumnIsAutoIncrement(int col) Returns true if the specified column auto-increments and false otherwise. -
getColumnIsAutoIncrement
Returns true if the specified column auto-increments and false otherwise. -
getColumnLength
public int getColumnLength(int col) Returns the length of the specified column. -
getColumnLength
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
Returns the length of the longest field in the specified column. -
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(). -
getResultSetId
public short getResultSetId()Returns the internal ID of this result set. This parameter may be passed to another cursor for use in the resumeResultSet() method. Note: the value returned by this method is only valid after a call to suspendResultSet(). -
resumeResultSet
public boolean resumeResultSet(short id) Resumes a result set previously left open using suspendSession(). Returns 1 on success and 0 on failure. -
resumeCachedResultSet
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. -
closeResultSet
public void closeResultSet()Closes the current result set, if one is open. Data that has been fetched already is still available but no more data may be fetched. Server side resources for the result set are freed as well. -
getDatabaseListWithFormat
-
getSchemaListWithFormat
-
getTableListWithFormat
-
getColumnListWithFormat
-