我有json / xml形式的数据,但是在数据库中是以bytea形式存储的,我怎么能以json / xml形式提取回来。
这是我的查询:
SELECT request_payload FROM unirate_incoming_request WHERE id='1224892672'
我得到的输出:
[
org.postgresql.jdbc42.Jdbc42ResultSet@119020fb
]
这是我的数据库查询:
public ResultSet payload(String a) throws SQLException {
ResultSet dboutput;
String query = " SELECT request_payload FROM unirate_incoming_request WHERE id='1224892672';
System.out.println(query);
DatabaseConnection dc = new DatabaseConnection(server, dbName, user, password);
dboutput = dc.executeQuery1(query);
System.out.println("hi");
while (dboutput.next()) {
System.out.print(dboutput.getBytes("request_payload") + " ");
}
dboutput.close();
dc.close();
return dboutput;
}
这是我的数据库连接:
public ResultSet executeQuery1(String sql) throws SQLException {
logSql(sql);
Statement stmt = createStatement();
ResultSet rs = stmt.executeQuery(sql);
return rs;
}