use of org.h2.command.dml.Set in project h2database by h2database.
the class JdbcResultSet method getAsciiStream.
/**
* Returns the value of the specified column as an input stream.
*
* @param columnLabel the column label
* @return the value
* @throws SQLException if the column is not found or if the result set is
* closed
*/
@Override
public InputStream getAsciiStream(String columnLabel) throws SQLException {
try {
debugCodeCall("getAsciiStream", columnLabel);
String s = get(columnLabel).getString();
return IOUtils.getInputStreamFromString(s);
} catch (Exception e) {
throw logAndConvert(e);
}
}
use of org.h2.command.dml.Set in project h2database by h2database.
the class JdbcResultSet method getObject.
/**
* Returns a column value as a Java object. The data is
* de-serialized into a Java object (on the client side).
*
* @param columnIndex (1,2,...)
* @return the value or null
* @throws SQLException if the column is not found or if the result set is
* closed
*/
@Override
public Object getObject(int columnIndex) throws SQLException {
try {
debugCodeCall("getObject", columnIndex);
Value v = get(columnIndex);
return conn.convertToDefaultObject(v);
} catch (Exception e) {
throw logAndConvert(e);
}
}
use of org.h2.command.dml.Set in project h2database by h2database.
the class JdbcConnection method prepareStatement.
/**
* Creates a prepared statement with the specified result set type,
* concurrency, and holdability.
*
* @param sql the SQL statement
* @param resultSetType the result set type (ResultSet.TYPE_*)
* @param resultSetConcurrency the concurrency (ResultSet.CONCUR_*)
* @param resultSetHoldability the holdability (ResultSet.HOLD* / CLOSE*)
* @return the prepared statement
* @throws SQLException if the connection is closed or the result set type,
* concurrency, or holdability are not supported
*/
@Override
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
try {
int id = getNextId(TraceObject.PREPARED_STATEMENT);
if (isDebugEnabled()) {
debugCodeAssign("PreparedStatement", TraceObject.PREPARED_STATEMENT, id, "prepareStatement(" + quote(sql) + ", " + resultSetType + ", " + resultSetConcurrency + ", " + resultSetHoldability + ")");
}
checkTypeConcurrency(resultSetType, resultSetConcurrency);
checkHoldability(resultSetHoldability);
checkClosed();
sql = translateSQL(sql);
return new JdbcPreparedStatement(this, sql, id, resultSetType, resultSetConcurrency, false, false);
} catch (Exception e) {
throw logAndConvert(e);
}
}
use of org.h2.command.dml.Set 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.Set in project h2database by h2database.
the class JdbcDatabaseMetaData method getSchemas.
/**
* Gets the list of schemas.
* The result set is sorted by TABLE_SCHEM.
*
* <ol>
* <li>TABLE_SCHEM (String) schema name</li>
* <li>TABLE_CATALOG (String) catalog name</li>
* <li>IS_DEFAULT (boolean) if this is the default schema</li>
* </ol>
*
* @return the schema list
* @throws SQLException if the connection is closed
*/
@Override
public ResultSet getSchemas() throws SQLException {
try {
debugCodeCall("getSchemas");
checkClosed();
PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT " + "SCHEMA_NAME TABLE_SCHEM, " + "CATALOG_NAME TABLE_CATALOG, " + " IS_DEFAULT " + "FROM INFORMATION_SCHEMA.SCHEMATA " + "ORDER BY SCHEMA_NAME");
return prep.executeQuery();
} catch (Exception e) {
throw logAndConvert(e);
}
}
Aggregations