1
에서 키 쌍 얻을 :SQLite는 일식, 내가 바이트 데이터베이스에 키 쌍을 저장 데이터베이스
byte[] pubkey = pair.getPublic().getEncoded();
byte[] privkey = pair.getPrivate().getEncoded();
String sql = "INSERT INTO certs(name, pubkey, privkey) VALUES(?,?,?)";
try (Connection conn = connect();
PreparedStatement pstmt = conn.prepareStatement(sql)) {
pstmt.setString(1, name);
pstmt.setBytes(2, pubkey);
pstmt.setBytes(3, privkey);
pstmt.executeUpdate();
} catch (SQLException e) {
System.out.println(e.getMessage());
}
이 작동합니다. 그러나 데이터베이스에서 키를 가져 오려고 할 때 키를 가져 오지 않습니다.
public static byte[] getPubKey(String name){
String sql = "SELECT pubkey FROM certs WHERE name = ?";
byte[] result = null;
try (Connection conn = connect();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql)){
result = rs.getBytes(1);
} catch (SQLException e) {
System.out.println(e.getMessage());
}
return result;
}
이 반환
나는이 문제를 어떻게 해결할 수
의 ResultSet이 null 폐쇄? 어떻게 키를 다시 일반 키 형식으로 포맷 할 수 있습니까?
pubkey가 내 검색어입니까? – nolags
아니요, 이름 ... –
이 (가) 추가되었습니다. pstmt.setString (1, name); 이제 작동합니다. – nolags