stmt = connection.prepareStatement(
"INSERT OR REPLACE INTO Keys (id, data, modified) "
+ "VALUES (?, ?, datetime('now'))");
stmt.setString(1, keyIdentifier);
} catch (SQLException ex) {
throw new StoreIOException(StoreIOException.Reason.DRIVER_SPECIFIC, ex);
}
insertStmt = stmt;
}
// Convert key contents to byte array
ByteString bytes;
try {
bytes = key.buildData().build().toByteString();
} catch (RuntimeException ex) {
throw new StoreIOException(
StoreIOException.Reason.SERIALIZATION_ERROR, ex);
}
// Insert/update key in database table
try {
stmt.setBytes(2, bytes.toByteArray());
stmt.executeUpdate();
} catch (SQLException ex) {
throw new StoreIOException(StoreIOException.Reason.WRITE_ERROR, ex);
}
}