use of org.h2.command.dml.Update in project h2database by h2database.
the class JdbcResultSet method updateBlob.
/**
* Updates a column in the current or insert row.
*
* @param columnIndex (1,2,...)
* @param x the value
* @param length the length
* @throws SQLException if the result set is closed or not updatable
*/
@Override
public void updateBlob(int columnIndex, InputStream x, long length) throws SQLException {
try {
if (isDebugEnabled()) {
debugCode("updateBlob(" + columnIndex + ", x, " + length + "L);");
}
checkClosed();
Value v = conn.createBlob(x, length);
update(columnIndex, v);
} catch (Exception e) {
throw logAndConvert(e);
}
}
use of org.h2.command.dml.Update in project h2database by h2database.
the class JdbcResultSet method updateBinaryStream.
/**
* Updates a column in the current or insert row.
*
* @param columnIndex (1,2,...)
* @param x the value
* @param length the number of characters
* @throws SQLException if the result set is closed or not updatable
*/
@Override
public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
try {
if (isDebugEnabled()) {
debugCode("updateBinaryStream(" + columnIndex + ", x, " + length + "L);");
}
checkClosed();
Value v = conn.createBlob(x, length);
update(columnIndex, v);
} catch (Exception e) {
throw logAndConvert(e);
}
}
use of org.h2.command.dml.Update in project h2database by h2database.
the class JdbcResultSet method updateClob.
/**
* Updates a column in the current or insert row.
*
* @param columnLabel the column label
* @param x the value
* @throws SQLException if the result set is closed or not updatable
*/
@Override
public void updateClob(String columnLabel, Clob x) throws SQLException {
try {
if (isDebugEnabled()) {
debugCode("updateClob(" + quote(columnLabel) + ", x);");
}
checkClosed();
Value v;
if (x == null) {
v = ValueNull.INSTANCE;
} else {
v = conn.createClob(x.getCharacterStream(), -1);
}
update(columnLabel, v);
} catch (Exception e) {
throw logAndConvert(e);
}
}
use of org.h2.command.dml.Update in project h2database by h2database.
the class JdbcDatabaseMetaData method getCrossReference.
/**
* Gets the list of foreign key columns that references a table, as well as
* the list of primary key columns that are references by a table. The
* result set is sorted by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME,
* FK_NAME, KEY_SEQ.
*
* <ol>
* <li>PKTABLE_CAT (String) primary catalog</li>
* <li>PKTABLE_SCHEM (String) primary schema</li>
* <li>PKTABLE_NAME (String) primary table</li>
* <li>PKCOLUMN_NAME (String) primary column</li>
* <li>FKTABLE_CAT (String) foreign catalog</li>
* <li>FKTABLE_SCHEM (String) foreign schema</li>
* <li>FKTABLE_NAME (String) foreign table</li>
* <li>FKCOLUMN_NAME (String) foreign column</li>
* <li>KEY_SEQ (short) sequence number (1,2,...)</li>
* <li>UPDATE_RULE (short) action on update (see
* DatabaseMetaData.importedKey...)</li>
* <li>DELETE_RULE (short) action on delete (see
* DatabaseMetaData.importedKey...)</li>
* <li>FK_NAME (String) foreign key name</li>
* <li>PK_NAME (String) primary key name</li>
* <li>DEFERRABILITY (short) deferrable or not (always
* importedKeyNotDeferrable)</li>
* </ol>
*
* @param primaryCatalogPattern null or the catalog name
* @param primarySchemaPattern the schema name of the primary table
* (optional)
* @param primaryTable the name of the primary table (must be specified)
* @param foreignCatalogPattern null or the catalog name
* @param foreignSchemaPattern the schema name of the foreign table
* (optional)
* @param foreignTable the name of the foreign table (must be specified)
* @return the result set
* @throws SQLException if the connection is closed
*/
@Override
public ResultSet getCrossReference(String primaryCatalogPattern, String primarySchemaPattern, String primaryTable, String foreignCatalogPattern, String foreignSchemaPattern, String foreignTable) throws SQLException {
try {
if (isDebugEnabled()) {
debugCode("getCrossReference(" + quote(primaryCatalogPattern) + ", " + quote(primarySchemaPattern) + ", " + quote(primaryTable) + ", " + quote(foreignCatalogPattern) + ", " + quote(foreignSchemaPattern) + ", " + quote(foreignTable) + ");");
}
checkClosed();
PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " + "PKTABLE_CATALOG PKTABLE_CAT, " + "PKTABLE_SCHEMA PKTABLE_SCHEM, " + "PKTABLE_NAME PKTABLE_NAME, " + "PKCOLUMN_NAME, " + "FKTABLE_CATALOG FKTABLE_CAT, " + "FKTABLE_SCHEMA FKTABLE_SCHEM, " + "FKTABLE_NAME, " + "FKCOLUMN_NAME, " + "ORDINAL_POSITION KEY_SEQ, " + "UPDATE_RULE, " + "DELETE_RULE, " + "FK_NAME, " + "PK_NAME, " + "DEFERRABILITY " + "FROM INFORMATION_SCHEMA.CROSS_REFERENCES " + "WHERE PKTABLE_CATALOG LIKE ? ESCAPE ? " + "AND PKTABLE_SCHEMA LIKE ? ESCAPE ? " + "AND PKTABLE_NAME = ? " + "AND FKTABLE_CATALOG LIKE ? ESCAPE ? " + "AND FKTABLE_SCHEMA LIKE ? ESCAPE ? " + "AND FKTABLE_NAME = ? " + "ORDER BY FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, FK_NAME, KEY_SEQ");
prep.setString(1, getCatalogPattern(primaryCatalogPattern));
prep.setString(2, "\\");
prep.setString(3, getSchemaPattern(primarySchemaPattern));
prep.setString(4, "\\");
prep.setString(5, primaryTable);
prep.setString(6, getCatalogPattern(foreignCatalogPattern));
prep.setString(7, "\\");
prep.setString(8, getSchemaPattern(foreignSchemaPattern));
prep.setString(9, "\\");
prep.setString(10, foreignTable);
return prep.executeQuery();
} catch (Exception e) {
throw logAndConvert(e);
}
}
use of org.h2.command.dml.Update in project h2database by h2database.
the class JdbcDatabaseMetaData method getImportedKeys.
/**
* Gets the list of primary key columns that are referenced by a table. The
* result set is sorted by PKTABLE_CAT, PKTABLE_SCHEM, PKTABLE_NAME,
* FK_NAME, KEY_SEQ.
*
* <ol>
* <li>PKTABLE_CAT (String) primary catalog</li>
* <li>PKTABLE_SCHEM (String) primary schema</li>
* <li>PKTABLE_NAME (String) primary table</li>
* <li>PKCOLUMN_NAME (String) primary column</li>
* <li>FKTABLE_CAT (String) foreign catalog</li>
* <li>FKTABLE_SCHEM (String) foreign schema</li>
* <li>FKTABLE_NAME (String) foreign table</li>
* <li>FKCOLUMN_NAME (String) foreign column</li>
* <li>KEY_SEQ (short) sequence number (1, 2, ...)</li>
* <li>UPDATE_RULE (short) action on update (see
* DatabaseMetaData.importedKey...)</li>
* <li>DELETE_RULE (short) action on delete (see
* DatabaseMetaData.importedKey...)</li>
* <li>FK_NAME (String) foreign key name</li>
* <li>PK_NAME (String) primary key name</li>
* <li>DEFERRABILITY (short) deferrable or not (always
* importedKeyNotDeferrable)</li>
* </ol>
*
* @param catalogPattern null (to get all objects) or the catalog name
* @param schemaPattern the schema name of the foreign table
* @param tableName the name of the foreign table
* @return the result set
* @throws SQLException if the connection is closed
*/
@Override
public ResultSet getImportedKeys(String catalogPattern, String schemaPattern, String tableName) throws SQLException {
try {
if (isDebugEnabled()) {
debugCode("getImportedKeys(" + quote(catalogPattern) + ", " + quote(schemaPattern) + ", " + quote(tableName) + ");");
}
checkClosed();
PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " + "PKTABLE_CATALOG PKTABLE_CAT, " + "PKTABLE_SCHEMA PKTABLE_SCHEM, " + "PKTABLE_NAME PKTABLE_NAME, " + "PKCOLUMN_NAME, " + "FKTABLE_CATALOG FKTABLE_CAT, " + "FKTABLE_SCHEMA FKTABLE_SCHEM, " + "FKTABLE_NAME, " + "FKCOLUMN_NAME, " + "ORDINAL_POSITION KEY_SEQ, " + "UPDATE_RULE, " + "DELETE_RULE, " + "FK_NAME, " + "PK_NAME, " + "DEFERRABILITY " + "FROM INFORMATION_SCHEMA.CROSS_REFERENCES " + "WHERE FKTABLE_CATALOG LIKE ? ESCAPE ? " + "AND FKTABLE_SCHEMA LIKE ? ESCAPE ? " + "AND FKTABLE_NAME = ? " + "ORDER BY PKTABLE_CAT, PKTABLE_SCHEM, PKTABLE_NAME, FK_NAME, KEY_SEQ");
prep.setString(1, getCatalogPattern(catalogPattern));
prep.setString(2, "\\");
prep.setString(3, getSchemaPattern(schemaPattern));
prep.setString(4, "\\");
prep.setString(5, tableName);
return prep.executeQuery();
} catch (Exception e) {
throw logAndConvert(e);
}
}
Aggregations