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


Java ResultSet.getBytes方法代码示例

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


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

示例1: viewSingle

import java.sql.ResultSet; //导入方法依赖的package包/类
public void viewSingle() throws SQLException, IOException {
	Connection c;
	c = database.SqliteConnection.getConnection();
	String SQL = "SELECT * from Employee";
	ResultSet rs = c.createStatement().executeQuery(SQL);
	while (rs.next()) {
		namelbl.setText(rs.getString(2));
		emaillbl.setText(rs.getString(3));
		moblbl.setText(rs.getString(4));
		addlbl.setText(rs.getString(5));
		addlbl.setWrapText(true);
		doblbl.setText(rs.getString(6));
		sexlbl.setText(rs.getString(7));
		fnamelbl.setText(rs.getString(8));
		byte[] imageInbyte = rs.getBytes(9);
		BufferedImage img1 = ImageIO.read(new ByteArrayInputStream(imageInbyte));
		Image image = SwingFXUtils.toFXImage(img1, null);
		photo.setImage(image);
		photo.setPreserveRatio(true);
	}
	c.close();
}
 
开发者ID:djdivix,项目名称:IDBuilderFX,代码行数:23,代码来源:ViewSingleParsedController.java

示例2: getRawMessage

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
@Nullable
public byte[] getRawMessage(Connection txn, MessageId m)
		throws DbException {
	PreparedStatement ps = null;
	ResultSet rs = null;
	try {
		String sql = "SELECT raw FROM messages WHERE messageId = ?";
		ps = txn.prepareStatement(sql);
		ps.setBytes(1, m.getBytes());
		rs = ps.executeQuery();
		if (!rs.next()) throw new DbStateException();
		byte[] raw = rs.getBytes(1);
		if (rs.next()) throw new DbStateException();
		rs.close();
		ps.close();
		return raw;
	} catch (SQLException e) {
		tryToClose(rs);
		tryToClose(ps);
		throw new DbException(e);
	}
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:24,代码来源:JdbcDatabase.java

示例3: getGroups

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public Collection<Group> getGroups(Connection txn, ClientId c)
		throws DbException {
	PreparedStatement ps = null;
	ResultSet rs = null;
	try {
		String sql = "SELECT groupId, descriptor FROM groups"
				+ " WHERE clientId = ?";
		ps = txn.prepareStatement(sql);
		ps.setString(1, c.getString());
		rs = ps.executeQuery();
		List<Group> groups = new ArrayList<Group>();
		while (rs.next()) {
			GroupId id = new GroupId(rs.getBytes(1));
			byte[] descriptor = rs.getBytes(2);
			groups.add(new Group(id, c, descriptor));
		}
		rs.close();
		ps.close();
		return groups;
	} catch (SQLException e) {
		tryToClose(rs);
		tryToClose(ps);
		throw new DbException(e);
	}
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:27,代码来源:JdbcDatabase.java

示例4: PreparedStmtSetValue

import java.sql.ResultSet; //导入方法依赖的package包/类
public static Object PreparedStmtSetValue(int columnType, ResultSet rs, int index) throws SQLException, IOException{
	StringBuffer sb = new StringBuffer();
	switch(columnType){
	case 2005:  //CLOB
		Clob clob = rs.getClob(index);
		
		if (clob == null){
			return null;
		}
		
		Reader reader = clob.getCharacterStream();
		char[] buffer = new char[(int)clob.length()];
		while(reader.read(buffer) != -1){
			sb.append(buffer);				
		}
		return sb.toString();
	case 2004:  //BLOB			
		Blob blob = rs.getBlob(index);
		
		if (blob == null){
			return null;
		}
		
		InputStream in = blob.getBinaryStream();
		byte[] Bytebuffer = new byte[(int)blob.length()];
		in.read(Bytebuffer);
		return Bytebuffer;
	case -2:
		return rs.getBytes(index);
	default:
		return rs.getObject(index);
	}	
}
 
开发者ID:experdb,项目名称:eXperDB-DB2PG,代码行数:34,代码来源:DatabaseUtil.java

示例5: printEmployees

import java.sql.ResultSet; //导入方法依赖的package包/类
private static void printEmployees() throws SQLException {
	Statement stmt = c.createStatement();
	String sql = "SELECT * FROM employees";
	ResultSet rs = stmt.executeQuery(sql);
	while (rs.next()) {
		int id = rs.getInt("id");
		String name = rs.getString("name");
		Date dob = rs.getDate("dob");
		String address = rs.getString("address");
		Double salary = rs.getDouble("salary");
		byte[] photo = rs.getBytes("photo");
		Department dep = getDepartments(rs.getInt("dep_id"));
		Employee employee = new Employee(id, name, dob, address, salary, photo, dep);
		System.out.println(employee);
	}
	rs.close();
	stmt.close();
}
 
开发者ID:rgarciacarmona,项目名称:JPA-Demo,代码行数:19,代码来源:SQLDelete.java

示例6: testUpdatableBlobsWithCharsets

import java.sql.ResultSet; //导入方法依赖的package包/类
/**
 * @throws Exception
 */
public void testUpdatableBlobsWithCharsets() throws Exception {
    byte[] smallBlob = new byte[32];

    for (byte i = 0; i < smallBlob.length; i++) {
        smallBlob[i] = i;
    }

    createTable("testUpdatableBlobsWithCharsets", "(pk INT NOT NULL PRIMARY KEY, field1 BLOB)");
    this.pstmt = this.conn.prepareStatement("INSERT INTO testUpdatableBlobsWithCharsets (pk, field1) VALUES (1, ?)");
    this.pstmt.setBinaryStream(1, new ByteArrayInputStream(smallBlob), smallBlob.length);
    this.pstmt.executeUpdate();

    Statement updStmt = this.conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

    this.rs = updStmt.executeQuery("SELECT pk, field1 FROM testUpdatableBlobsWithCharsets");
    System.out.println(this.rs);
    this.rs.next();

    for (byte i = 0; i < smallBlob.length; i++) {
        smallBlob[i] = (byte) (i + 32);
    }

    this.rs.updateBinaryStream(2, new ByteArrayInputStream(smallBlob), smallBlob.length);
    this.rs.updateRow();

    ResultSet newRs = this.stmt.executeQuery("SELECT field1 FROM testUpdatableBlobsWithCharsets");

    newRs.next();

    byte[] updatedBlob = newRs.getBytes(1);

    for (byte i = 0; i < smallBlob.length; i++) {
        byte origValue = smallBlob[i];
        byte newValue = updatedBlob[i];

        assertTrue("Original byte at position " + i + ", " + origValue + " != new value, " + newValue, origValue == newValue);
    }

}
 
开发者ID:rafallis,项目名称:BibliotecaPS,代码行数:43,代码来源:BlobRegressionTest.java

示例7: getMessageDependencies

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public Map<MessageId, State> getMessageDependencies(Connection txn,
		MessageId m) throws DbException {
	PreparedStatement ps = null;
	ResultSet rs = null;
	try {
		String sql = "SELECT d.dependencyId, m.state, d.groupId, m.groupId"
				+ " FROM messageDependencies AS d"
				+ " LEFT OUTER JOIN messages AS m"
				+ " ON d.dependencyId = m.messageId"
				+ " WHERE d.messageId = ?";
		ps = txn.prepareStatement(sql);
		ps.setBytes(1, m.getBytes());
		rs = ps.executeQuery();
		Map<MessageId, State> dependencies = new HashMap<MessageId, State>();
		while (rs.next()) {
			MessageId dependency = new MessageId(rs.getBytes(1));
			State state = State.fromValue(rs.getInt(2));
			if (rs.wasNull()) {
				state = UNKNOWN; // Missing dependency
			} else {
				GroupId dependentGroupId = new GroupId(rs.getBytes(3));
				GroupId dependencyGroupId = new GroupId(rs.getBytes(4));
				if (!dependentGroupId.equals(dependencyGroupId))
					state = INVALID; // Dependency in another group
			}
			dependencies.put(dependency, state);
		}
		rs.close();
		ps.close();
		return dependencies;
	} catch (SQLException e) {
		tryToClose(rs);
		tryToClose(ps);
		throw new DbException(e);
	}
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:38,代码来源:JdbcDatabase.java

示例8: ATState

import java.sql.ResultSet; //导入方法依赖的package包/类
private ATState(ResultSet rs) throws SQLException {
	this.atId = rs.getLong("at_id");
	this.dbKey = atStateDbKeyFactory.newKey(this.atId);
	this.state = rs.getBytes("state");
	this.prevHeight = rs.getInt("prev_height");
	this.nextHeight = rs.getInt("next_height");
	this.sleepBetween = rs.getInt("sleep_between");
	this.prevBalance = rs.getLong("prev_balance");
	this.freezeWhenSameBalance = rs.getBoolean("freeze_when_same_balance");
	this.minActivationAmount = rs.getLong("min_activate_amount");
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:12,代码来源:AT.java

示例9: getLocalAuthor

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public LocalAuthor getLocalAuthor(Connection txn, AuthorId a)
		throws DbException {
	PreparedStatement ps = null;
	ResultSet rs = null;
	try {
		String sql = "SELECT name, publicKey, privateKey, created"
				+ " FROM localAuthors"
				+ " WHERE authorId = ?";
		ps = txn.prepareStatement(sql);
		ps.setBytes(1, a.getBytes());
		rs = ps.executeQuery();
		if (!rs.next()) throw new DbStateException();
		String name = rs.getString(1);
		byte[] publicKey = rs.getBytes(2);
		byte[] privateKey = rs.getBytes(3);
		long created = rs.getLong(4);
		LocalAuthor localAuthor = new LocalAuthor(a, name, publicKey,
				privateKey, created);
		if (rs.next()) throw new DbStateException();
		rs.close();
		ps.close();
		return localAuthor;
	} catch (SQLException e) {
		tryToClose(rs);
		tryToClose(ps);
		throw new DbException(e);
	}
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:30,代码来源:JdbcDatabase.java

示例10: Account

import java.sql.ResultSet; //导入方法依赖的package包/类
private Account(ResultSet rs) throws SQLException {
    this.id = rs.getLong("id");
    this.dbKey = accountDbKeyFactory.newKey(this.id);
    this.creationHeight = rs.getInt("creation_height");
    this.publicKey = rs.getBytes("public_key");
    this.keyHeight = rs.getInt("key_height");
    this.balanceNQT = rs.getLong("balance");
    this.unconfirmedBalanceNQT = rs.getLong("unconfirmed_balance");
    this.forgedBalanceNQT = rs.getLong("forged_balance");
    this.name = rs.getString("name");
    this.description = rs.getString("description");
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:13,代码来源:Account.java

示例11: getString

import java.sql.ResultSet; //导入方法依赖的package包/类
public String getString(int n) {
    try {
        ResultSet rs = getResultSet();
        if (rs == null) {
            return "";
        }
        return new String(rs.getBytes(n));
    } catch (Exception e) {
        Debug.warning(e);
        return "";
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:13,代码来源:Database.java

示例12: getBlobAsBytes

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public byte[] getBlobAsBytes(ResultSet rs, int columnIndex) throws SQLException {
	logger.debug("Returning BLOB as bytes");
	if (this.wrapAsLob) {
		Blob blob = rs.getBlob(columnIndex);
		return blob.getBytes(1, (int) blob.length());
	}
	else {
		return rs.getBytes(columnIndex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:DefaultLobHandler.java

示例13: readTabProfileTest

import java.sql.ResultSet; //导入方法依赖的package包/类
static void readTabProfileTest(Statement sStatement) throws Exception {

        String    s = "select * from TabProfile where id=-2";
        ResultSet r = sStatement.executeQuery(s);

        r.next();

        if (!r.getString(2).equals("\"Birdie\"'s car ?")) {
            throw new Exception("Unicode error.");
        }

        boolean mismatch = false;
        byte[]  b2n      = r.getBytes(4);

        for (int i = 0; i < b2n.length; i++) {
            if (b2[i] != b2n[i]) {
                mismatch = true;
            }
        }

        r.close();

        s = "select * from TabProfile where id=10";
        r = sStatement.executeQuery(s);

        r.next();

        byte[] b1n = r.getBytes(4);

        for (int i = 0; i < b1n.length; i++) {
            if (b1[i] != b1n[i]) {
                mismatch = true;
            }
        }

        r.close();
    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:38,代码来源:TestSelf.java

示例14: by

import java.sql.ResultSet; //导入方法依赖的package包/类
@And("^a point on \"([^\"]*)\" \"([^\"]*)\" will be rolled up by (\\d+) \"([^\"]*)\" with a double (\\d+)$")
public void aPointOnWillBeRolledUpByWithADouble(String timestampState,
                                                String timestampUnit,
                                                long granularityValue,
                                                String granularityUnit,
                                                Double expectedValue) throws Throwable {
    String sql = ""
            + " SELECT \"value\"          "
            + " FROM   point_" + granularityOf(granularityValue, granularityUnit)
            + " WHERE  \"metric_id\" = ?   "
            + " AND    \"timestamp\" = ?   "
            + " AND    \"aggregation\" = ? ";

    Timestamp timestamp = resolveTimestamp(timestampState, timestampUnit);

    try (Connection connection = pugTSDB.getDataSource().getConnection();
         PreparedStatement statement = connection.prepareStatement(sql)) {
        statement.setInt(1, metric.getId());
        statement.setTimestamp(2, timestamp);
        statement.setString(3, aggregation.getName());
        ResultSet resultSet = statement.executeQuery();

        assertTrue(resultSet.next());

        byte[] actualBytes = resultSet.getBytes(1);
        Object actualValue = metric.valueFromBytes(actualBytes);

        if (expectedValue == null) {
            assertNull(actualValue);
        } else {
            assertEquals(expectedValue, actualValue);
        }
    }
}
 
开发者ID:StefaniniInspiring,项目名称:pugtsdb,代码行数:35,代码来源:RollUpGranularitySteps.java

示例15: populateMessageWithMetadata

import java.sql.ResultSet; //导入方法依赖的package包/类
@SuppressFBWarnings("SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING")
private void populateMessageWithMetadata(Connection connection,
                                         String idListAsString, List<Long> idList,
                                         Map<Long, Message> messageMap) throws SQLException, BrokerException {
    String metadataSql = "SELECT MESSAGE_ID, EXCHANGE_NAME, ROUTING_KEY, CONTENT_LENGTH, MESSAGE_METADATA "
            + " FROM MB_METADATA WHERE MESSAGE_ID IN (" + idListAsString + ") ORDER BY MESSAGE_ID";


    PreparedStatement selectMetadata = null;
    ResultSet metadataResultSet = null;

    try {
        selectMetadata = connection.prepareStatement(metadataSql);
        for (int i = 0; i < idList.size(); i++) {
            selectMetadata.setLong(i + 1, idList.get(i));
        }

        metadataResultSet = selectMetadata.executeQuery();
        while (metadataResultSet.next()) {
            long messageId = metadataResultSet.getLong(1);
            String exchangeName = metadataResultSet.getString(2);
            String routingKey = metadataResultSet.getString(3);
            long contentLength = metadataResultSet.getLong(4);
            byte[] bytes = metadataResultSet.getBytes(5);
            ByteBuf buffer = Unpooled.wrappedBuffer(bytes);
            try {
                Metadata metadata = new Metadata(messageId, routingKey, exchangeName, contentLength);
                metadata.setProperties(FieldTable.parse(buffer));
                metadata.setHeaders(FieldTable.parse(buffer));
                Message message = new Message(metadata);
                messageMap.put(messageId, message);
            } catch (Exception e) {
                throw new BrokerException("Error occurred while parsing metadata properties", e);
            } finally {
                buffer.release();
            }
        }
    } finally {
        close(metadataResultSet);
        close(selectMetadata);
    }
}
 
开发者ID:wso2,项目名称:message-broker,代码行数:43,代码来源:MessageDaoImpl.java


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