Package org.h2.result
Class UpdatableRow
- java.lang.Object
-
- org.h2.result.UpdatableRow
-
public class UpdatableRow extends java.lang.Object
This class is used for updatable result sets. An updatable row provides functions to update the current row in a result set.
-
-
Field Summary
Fields Modifier and Type Field Description private int
columnCount
private JdbcConnection
conn
private boolean
isUpdatable
private java.util.ArrayList<java.lang.String>
key
private ResultInterface
result
private java.lang.String
schemaName
private java.lang.String
tableName
-
Constructor Summary
Constructors Constructor Description UpdatableRow(JdbcConnection conn, ResultInterface result)
Construct a new object that is linked to the result set.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
appendColumnList(java.lang.StringBuilder builder, boolean set)
private void
appendKeyCondition(java.lang.StringBuilder builder)
private void
appendTableName(java.lang.StringBuilder builder)
void
deleteRow(Value[] current)
Delete the given row in the database.private int
findColumnIndex(java.lang.String columnName)
private int
getColumnIndex(java.lang.String columnName)
void
insertRow(Value[] row)
Insert a new row into the database.private boolean
isIndexUsable(java.util.ArrayList<java.lang.String> indexColumns)
boolean
isUpdatable()
Check if this result set is updatable.Value[]
readRow(Value[] row)
Re-reads a row from the database and updates the values in the array.private void
setKey(java.sql.PreparedStatement prep, int start, Value[] current)
void
updateRow(Value[] current, Value[] updateRow)
Update a row in the database.
-
-
-
Field Detail
-
conn
private final JdbcConnection conn
-
result
private final ResultInterface result
-
columnCount
private final int columnCount
-
schemaName
private java.lang.String schemaName
-
tableName
private java.lang.String tableName
-
key
private java.util.ArrayList<java.lang.String> key
-
isUpdatable
private boolean isUpdatable
-
-
Constructor Detail
-
UpdatableRow
public UpdatableRow(JdbcConnection conn, ResultInterface result) throws java.sql.SQLException
Construct a new object that is linked to the result set. The constructor reads the database meta data to find out if the result set is updatable.- Parameters:
conn
- the database connectionresult
- the result- Throws:
java.sql.SQLException
- on failure
-
-
Method Detail
-
isIndexUsable
private boolean isIndexUsable(java.util.ArrayList<java.lang.String> indexColumns)
-
isUpdatable
public boolean isUpdatable()
Check if this result set is updatable.- Returns:
- true if it is
-
findColumnIndex
private int findColumnIndex(java.lang.String columnName)
-
getColumnIndex
private int getColumnIndex(java.lang.String columnName)
-
appendColumnList
private void appendColumnList(java.lang.StringBuilder builder, boolean set)
-
appendKeyCondition
private void appendKeyCondition(java.lang.StringBuilder builder)
-
setKey
private void setKey(java.sql.PreparedStatement prep, int start, Value[] current) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
appendTableName
private void appendTableName(java.lang.StringBuilder builder)
-
readRow
public Value[] readRow(Value[] row) throws java.sql.SQLException
Re-reads a row from the database and updates the values in the array.- Parameters:
row
- the values that contain the key- Returns:
- the row
- Throws:
java.sql.SQLException
- on failure
-
deleteRow
public void deleteRow(Value[] current) throws java.sql.SQLException
Delete the given row in the database.- Parameters:
current
- the row- Throws:
java.sql.SQLException
- if this row has already been deleted
-
updateRow
public void updateRow(Value[] current, Value[] updateRow) throws java.sql.SQLException
Update a row in the database.- Parameters:
current
- the old rowupdateRow
- the new row- Throws:
java.sql.SQLException
- if the row has been deleted
-
insertRow
public void insertRow(Value[] row) throws java.sql.SQLException
Insert a new row into the database.- Parameters:
row
- the new row- Throws:
java.sql.SQLException
- if the row could not be inserted
-
-