本文整理汇总了Java中java.sql.ResultSet.TYPE_FORWARD_ONLY属性的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.TYPE_FORWARD_ONLY属性的具体用法?Java ResultSet.TYPE_FORWARD_ONLY怎么用?Java ResultSet.TYPE_FORWARD_ONLY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.sql.ResultSet
的用法示例。
在下文中一共展示了ResultSet.TYPE_FORWARD_ONLY属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: supportsResultSetConcurrency
/**
* JDBC 2.0 Does the database support the concurrency type in combination
* with the given result set type?
*
* @param type
* defined in java.sql.ResultSet
* @param concurrency
* type defined in java.sql.ResultSet
* @return true if so
* @exception SQLException
* if a database-access error occurs.
* @see Connection
*/
public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException {
switch (type) {
case ResultSet.TYPE_SCROLL_INSENSITIVE:
if ((concurrency == ResultSet.CONCUR_READ_ONLY) || (concurrency == ResultSet.CONCUR_UPDATABLE)) {
return true;
}
throw SQLError.createSQLException("Illegal arguments to supportsResultSetConcurrency()", SQLError.SQL_STATE_ILLEGAL_ARGUMENT,
getExceptionInterceptor());
case ResultSet.TYPE_FORWARD_ONLY:
if ((concurrency == ResultSet.CONCUR_READ_ONLY) || (concurrency == ResultSet.CONCUR_UPDATABLE)) {
return true;
}
throw SQLError.createSQLException("Illegal arguments to supportsResultSetConcurrency()", SQLError.SQL_STATE_ILLEGAL_ARGUMENT,
getExceptionInterceptor());
case ResultSet.TYPE_SCROLL_SENSITIVE:
return false;
default:
throw SQLError.createSQLException("Illegal arguments to supportsResultSetConcurrency()", SQLError.SQL_STATE_ILLEGAL_ARGUMENT,
getExceptionInterceptor());
}
}
示例2: doQuery
@Override
public ResultSet doQuery(final SqlContext sqlContext, final PreparedStatement preparedStatement,
final ResultSet resultSet) {
// カウント初期値
int rowCount = -1;
try {
// resultSetのカーソル種別を取得
// 種別「TYPE_FORWARD_ONLY」の場合、beforeFirstメソッドが効かないため除外
if (resultSet.getType() != ResultSet.TYPE_FORWARD_ONLY) {
// 件数結果取得
resultSet.last();
rowCount = resultSet.getRow();
resultSet.beforeFirst();
}
} catch (SQLException e) {
// ここでの例外は実処理に影響を及ぼさないよう握りつぶす
}
String userName = getParam(sqlContext, USER_NAME_KEY);
if (userName == null) {
// ユーザ名が設定されていない時
userName = DEFAULT_USER_NAME;
}
String funcId = getParam(sqlContext, FUNC_ID_KEY);
if (funcId == null) {
// 機能IDが設定されていない時
funcId = DEFAULT_FUNC_ID;
}
LOG.debug(ToStringBuilder.reflectionToString(
new AuditData(userName, funcId, sqlContext.getSqlId(), sqlContext.getSqlName(), sqlContext
.getExecutableSql(), rowCount), ToStringStyle.JSON_STYLE));
return resultSet;
}
示例3: getResultSetType
public int getResultSetType() throws SQLException {
try {
if (this.wrappedStmt != null) {
return this.wrappedStmt.getResultSetType();
}
throw SQLError.createSQLException("Statement already closed", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
return ResultSet.TYPE_FORWARD_ONLY;
}
示例4: updateScrollableSupport
/**
* Determine if DBMS/Driver supports scrollable resultsets to be able to
* determine complete row count for a given SQL.
*
* @param conn established JDBC connection
* @param dc connection information
* @param sql the sql to be executed
*/
private void updateScrollableSupport(Connection conn, DatabaseConnection dc,
String sql) {
useScrollableCursors = dc.isUseScrollableCursors();
if (!useScrollableCursors) {
return;
}
String driverName = dc.getDriverClass();
/* Derby fails to support scrollable cursors when invoking 'stored procedures'
which return resultsets - it fails hard: not throwing a SQLException,
but terminating the connection - so don't try to use scrollable cursor
on derby, for "non"-selects */
if (driverName != null && driverName.startsWith("org.apache.derby")) { //NOI18N
if (!isSelectStatement(sql)) {
resultSetScrollType = ResultSet.TYPE_FORWARD_ONLY;
return;
}
}
/* Try to get a "good" scrollable ResultSet and follow the DBs support */
try {
if (conn.getMetaData().supportsResultSetType(
ResultSet.TYPE_SCROLL_INSENSITIVE)) {
resultSetScrollType = ResultSet.TYPE_SCROLL_INSENSITIVE;
} else if (conn.getMetaData().supportsResultSetType(
ResultSet.TYPE_SCROLL_SENSITIVE)) {
resultSetScrollType = ResultSet.TYPE_SCROLL_SENSITIVE;
}
} catch (Exception ex) {
LOGGER.log(Level.WARNING, "Exception while querying" //NOI18N
+ " database for scrollable resultset support"); //NOI18N
}
}
示例5: isCursorRequired
@Override
boolean isCursorRequired() throws SQLException {
// we only create cursor-backed result sets if
// a) The query is a SELECT
// b) The server supports it
// c) We know it is forward-only (note this doesn't preclude updatable result sets)
// d) The user has set a fetch size
return this.resultFields != null && this.connection.isCursorFetchEnabled() && getResultSetType() == ResultSet.TYPE_FORWARD_ONLY
&& getResultSetConcurrency() == ResultSet.CONCUR_READ_ONLY && getFetchSize() > 0;
}
示例6: supportsResultSetType
public boolean supportsResultSetType(int type) throws SQLException {
if (type == ResultSet.TYPE_FORWARD_ONLY) {
return true;
}
if (type == ResultSet.TYPE_SCROLL_INSENSITIVE) {
// TODO あとでよく見る。
return false;
}
if (type == ResultSet.TYPE_SCROLL_SENSITIVE) {
// TODO あとでよく見る。
return true;
}
return false;
}
开发者ID:igapyon,项目名称:blanco-sfdc-jdbc-driver,代码行数:14,代码来源:AbstractBlancoGenericJdbcDatabaseMetaData.java
示例7: useServerFetch
private boolean useServerFetch() throws SQLException {
synchronized (checkClosed().getConnectionMutex()) {
return this.connection.isCursorFetchEnabled() && this.fetchSize > 0 && this.resultSetConcurrency == ResultSet.CONCUR_READ_ONLY
&& this.resultSetType == ResultSet.TYPE_FORWARD_ONLY;
}
}
示例8: getResultSetType
@Override
default int getResultSetType() throws SQLException {
return ResultSet.TYPE_FORWARD_ONLY;
}
示例9: supportsResultSetType
@Override
public boolean supportsResultSetType(int type) throws SQLException
{
return type == ResultSet.TYPE_FORWARD_ONLY;
}
示例10: getResultSetType
@Override
public int getResultSetType() throws SQLException {
checkConnection("getResultSetType");
return ResultSet.TYPE_FORWARD_ONLY;
}
示例11: supportsResultSetConcurrency
public boolean supportsResultSetConcurrency(
int type, int concurrency) throws SQLException {
return type == ResultSet.TYPE_FORWARD_ONLY
&& concurrency == ResultSet.CONCUR_READ_ONLY;
}
示例12: checkCreateStatementSupported
/**
* Check if the createStatement() options are supported
*
* See http://docs.oracle.com/javase/7/docs/api/index.html?java/sql/DatabaseMetaData.html
*
* The following flags are supported:
* - The type must either be TYPE_SCROLL_INSENSITIVE or TYPE_FORWARD_ONLY.
* - The concurrency must be CONCUR_READ_ONLY.
* - The holdability must be CLOSE_CURSORS_AT_COMMIT.
*
* @param resultSetType JDBC result set type option
* @param resultSetConcurrency JDBC result set concurrency option
* @param resultSetHoldability JDBC result set holdability option
* @throws SQLException if not supported
*/
private static void checkCreateStatementSupported(
int resultSetType, int resultSetConcurrency, int resultSetHoldability)
throws SQLException
{
if ( ( (resultSetType != ResultSet.TYPE_SCROLL_INSENSITIVE
&& resultSetType != ResultSet.TYPE_FORWARD_ONLY))
|| resultSetConcurrency != ResultSet.CONCUR_READ_ONLY
|| resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT) {
throw SQLError.noSupport();
}
}