当前位置: 首页>>代码示例>>Java>>正文


Java SQLException.toString方法代码示例

本文整理汇总了Java中java.sql.SQLException.toString方法的典型用法代码示例。如果您正苦于以下问题:Java SQLException.toString方法的具体用法?Java SQLException.toString怎么用?Java SQLException.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.sql.SQLException的用法示例。


在下文中一共展示了SQLException.toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sqlResultSetParse

import java.sql.SQLException; //导入方法依赖的package包/类
/**
 * 解析resultset中的条数
 * 
 * @param resultSet
 * @return
 */
private String sqlResultSetParse(ResultSet rset) {

    try {
        // 只能向前遍历的游标,只能用next()来遍历
        if (rset.getType() == ResultSet.TYPE_FORWARD_ONLY) {
            return "FORWARD_ONLY";
        }
        else {
            // 可以滚动的游标,在用户使用游标之前,直接获取结果集大小,然后游标回到开始的地方(假装游标没有移动过)
            rset.last();
            int row = rset.getRow();
            rset.beforeFirst();
            return row + "";

        }
    }
    catch (SQLException e) {
        return e.toString();
    }
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:27,代码来源:JdbcDriverAdapter.java

示例2: rollbackThis

import java.sql.SQLException; //导入方法依赖的package包/类
/**
 * This rolls back the connection associated with <i>this</i> XAResource.
 *
 * @throws javax.transaction.xa.XAException generically, since the more
 * specific exceptions require a JTA API to compile.
 */
/* @throws javax.transaction.HeuristicCommitException
 *         if work was committed.
 * @throws javax.transaction.HeuristicMixedException
 *         if some work was committed and some work was rolled back
 */
public void rollbackThis() throws XAException {

    if (state != XA_STATE_PREPARED && state != XA_STATE_ENDED) {
        throw new XAException("Invalid XAResource state");
    }

    try {

        /**
         * @todo:  Determine if work was committed, rolled back, or both,
         * and return appropriate Heuristic Exception.
         */
        connection.rollback();    // real/phys.
    } catch (SQLException se) {
        throw new XAException(se.toString());
    }

    dispose();
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:31,代码来源:JDBCXAResource.java

示例3: read

import java.sql.SQLException; //导入方法依赖的package包/类
@Override
public int read(byte[] b) throws IOException {
    if (this.currentPositionInBlob + 1 > this.length) {
        return -1;
    }

    try {
        byte[] asBytes = getBytesInternal(this.pStmt, (this.currentPositionInBlob) + 1, b.length);

        if (asBytes == null) {
            return -1;
        }

        System.arraycopy(asBytes, 0, b, 0, asBytes.length);

        this.currentPositionInBlob += asBytes.length;

        return asBytes.length;
    } catch (SQLException sqlEx) {
        throw new IOException(sqlEx.toString());
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:BlobFromLocator.java

示例4: getData

import java.sql.SQLException; //导入方法依赖的package包/类
TransferResultSet getData(String statement)
throws DataAccessPointException {

    ResultSet rsData = null;

    try {
        if (srcStatement != null) {
            srcStatement.close();
        }

        srcStatement = conn.createStatement();
        rsData       = srcStatement.executeQuery(statement);
    } catch (SQLException e) {
        try {
            srcStatement.close();
        } catch (Exception e1) {}

        srcStatement = null;
        rsData       = null;

        throw new DataAccessPointException(e.toString());
    }

    return new TransferResultSet(rsData);
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:26,代码来源:TransferDb.java

示例5: insert

import java.sql.SQLException; //导入方法依赖的package包/类
public final void insert(T t, List<V> values) {
    if (!Db.isInTransaction()) {
        throw new IllegalStateException("Not in transaction");
    }
    DbKey dbKey = dbKeyFactory.newKey(t);
    Db.getCache(table).put(dbKey, values);
    try (Connection con = Db.getConnection()) {
        if (multiversion) {
            try (PreparedStatement pstmt = con.prepareStatement("UPDATE " + table
                    + " SET latest = FALSE " + dbKeyFactory.getPKClause() + " AND latest = TRUE")) {
                dbKey.setPK(pstmt);
                pstmt.executeUpdate();
            }
        }
        for (V v : values) {
            save(con, t, v);
        }
    } catch (SQLException e) {
        throw new RuntimeException(e.toString(), e);
    }
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:22,代码来源:ValuesDbTable.java

示例6: test

import java.sql.SQLException; //导入方法依赖的package包/类
protected boolean test(Statement aStatement) {

        try {
            aStatement.execute(getSql());
        } catch (SQLException sqlX) {
            caught = sqlX;

            if (expectedState == null
                    || expectedState.equalsIgnoreCase(sqlX.getSQLState())) {
                return true;
            }

            message = "SQLState '" + sqlX.getSQLState() + "' : "
                      + sqlX.toString() + " instead of '" + expectedState
                      + "'";
        } catch (Exception x) {
            caught  = x;
            message = x.toString();
        }

        return false;
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:23,代码来源:TestUtil.java

示例7: getBlockIdsAfter

import java.sql.SQLException; //导入方法依赖的package包/类
@Override
public List<Long> getBlockIdsAfter(long blockId, int limit) {
    if (limit > 1440) {
        throw new IllegalArgumentException("Can't get more than 1440 blocks at a time");
    }
    try (Connection con = Db.getConnection();
         PreparedStatement pstmt = con.prepareStatement("SELECT id FROM block WHERE db_id > (SELECT db_id FROM block WHERE id = ?) ORDER BY db_id ASC LIMIT ?")) {
        List<Long> result = new ArrayList<>();
        pstmt.setLong(1, blockId);
        pstmt.setInt(2, limit);
        try (ResultSet rs = pstmt.executeQuery()) {
            while (rs.next()) {
                result.add(rs.getLong("id"));
            }
        }
        return result;
    } catch (SQLException e) {
        throw new RuntimeException(e.toString(), e);
    }
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:21,代码来源:BlockchainImpl.java

示例8: read

import java.sql.SQLException; //导入方法依赖的package包/类
@Override
public int read(byte[] b, int off, int len) throws IOException {
    if (this.currentPositionInBlob + 1 > this.length) {
        return -1;
    }

    try {
        byte[] asBytes = getBytesInternal(this.pStmt, (this.currentPositionInBlob) + 1, len);

        if (asBytes == null) {
            return -1;
        }

        System.arraycopy(asBytes, 0, b, off, asBytes.length);

        this.currentPositionInBlob += asBytes.length;

        return asBytes.length;
    } catch (SQLException sqlEx) {
        throw new IOException(sqlEx.toString());
    }
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:23,代码来源:BlobFromLocator.java

示例9: findTransaction

import java.sql.SQLException; //导入方法依赖的package包/类
protected static Long findTransaction(int startHeight , int endHeight , Long atID, int numOfTx, long minAmount){
	try (Connection con = Db.getConnection();
			PreparedStatement pstmt = con.prepareStatement("SELECT id FROM transaction "
					+ "WHERE height>= ? AND height < ? and recipient_id = ? AND amount >= ? "
					+ "ORDER BY height, id "
					+ "LIMIT 1 OFFSET ?")){
		pstmt.setInt(1, startHeight);
		pstmt.setInt(2, endHeight);
		pstmt.setLong(3, atID);
		pstmt.setLong(4, minAmount);
		pstmt.setInt(5, numOfTx);
		ResultSet rs = pstmt.executeQuery();
		Long transactionId = 0L;
		if(rs.next()) {
			transactionId = rs.getLong("id");
		}
		rs.close();
		return transactionId;

	} catch (SQLException e) {
		throw new RuntimeException(e.toString(), e);
	}

}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:25,代码来源:AT_API_Platform_Impl.java

示例10: get

import java.sql.SQLException; //导入方法依赖的package包/类
public final List<V> get(DbKey dbKey) {
    List<V> values;
    if (Db.isInTransaction()) {
        values = (List<V>)Db.getCache(table).get(dbKey);
        if (values != null) {
            return values;
        }
    }
    try (Connection con = Db.getConnection();
         PreparedStatement pstmt = con.prepareStatement("SELECT * FROM " + table + dbKeyFactory.getPKClause()
         + (multiversion ? " AND latest = TRUE" : "") + " ORDER BY db_id DESC")) {
        dbKey.setPK(pstmt);
        values = get(con, pstmt);
        if (Db.isInTransaction()) {
            Db.getCache(table).put(dbKey, values);
        }
        return values;
    } catch (SQLException e) {
        throw new RuntimeException(e.toString(), e);
    }
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:22,代码来源:ValuesDbTable.java

示例11: TransferDb

import java.sql.SQLException; //导入方法依赖的package包/类
TransferDb(Connection c, Traceable t) throws DataAccessPointException {

        super(t);

        conn = c;

        if (c != null) {
            String productLowerName;

            try {
                meta              = c.getMetaData();
                databaseToConvert = c.getCatalog();
                productLowerName  = meta.getDatabaseProductName();

                if (productLowerName == null) {
                    productLowerName = "";
                } else {
                    productLowerName = productLowerName.toLowerCase();
                }

                helper = HelperFactory.getHelper(productLowerName);

                helper.set(this, t, meta.getIdentifierQuoteString());
            } catch (SQLException e) {
                throw new DataAccessPointException(e.toString());
            }
        }
    }
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:29,代码来源:TransferDb.java

示例12: DbIterator

import java.sql.SQLException; //导入方法依赖的package包/类
public DbIterator(Connection con, PreparedStatement pstmt, ResultSetReader<T> rsReader) {
    this.con = con;
    this.pstmt = pstmt;
    this.rsReader = rsReader;
    try {
        this.rs = pstmt.executeQuery();
        this.hasNext = rs.next();
    } catch (SQLException e) {
        DbUtils.close(pstmt, con);
        throw new RuntimeException(e.toString(), e);
    }
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:13,代码来源:DbIterator.java

示例13: getTransactionCount

import java.sql.SQLException; //导入方法依赖的package包/类
@Override
public int getTransactionCount() {
    try (Connection con = Db.getConnection(); PreparedStatement pstmt = con.prepareStatement("SELECT COUNT(*) FROM transaction");
         ResultSet rs = pstmt.executeQuery()) {
        rs.next();
        return rs.getInt(1);
    } catch (SQLException e) {
        throw new RuntimeException(e.toString(), e);
    }
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:11,代码来源:BlockchainImpl.java

示例14: rollbackTransaction

import java.sql.SQLException; //导入方法依赖的package包/类
public static void rollbackTransaction() {
    DbConnection con = localConnection.get();
    if (con == null) {
        throw new IllegalStateException("Not in transaction");
    }
    try {
        con.doRollback();
    } catch (SQLException e) {
        throw new RuntimeException(e.toString(), e);
    }
    transactionCaches.get().clear();
    transactionBatches.get().clear();
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:14,代码来源:Db.java

示例15: setAutoCommit

import java.sql.SQLException; //导入方法依赖的package包/类
void setAutoCommit(boolean flag) throws DataAccessPointException {

        try {
            conn.setAutoCommit(flag);
        } catch (SQLException e) {
            throw new DataAccessPointException(e.toString());
        }
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:9,代码来源:TransferDb.java


注:本文中的java.sql.SQLException.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。