try { // 连接数据库
Connection conn = DriverManager.getConnection(url, username, password);
// 创建查询语句
Statement stmt = conn.createStatement();
String sql = "SELECT * FROM table_name WHERE id = 1";
// 执行查询
ResultSet rs = stmt.executeQuery(sql);
// 获取数据
if (rs.next()) {
byte[] data = rs.getBytes(1);
// 处理数据
//
... }
// 关闭连接
rs.close();
stmt.close();
conn.close();
}
catch (SQLException e)
{
e.printStackTrace();}
数据库查出的数据转换为byte[]
最新推荐文章于 2024-05-07 10:26:13 发布