我正在開發一個用Java語言設計的生物識別考勤系統,用於digitalPersona設備的MySQL。但是在指紋驗證期間,每當它顯示不同的數據時,我都會從數據庫中檢索指紋數據(即BLOB)。最終結果顯示「未驗證」。以下是我爲驗證寫的代碼。指紋驗證在DigitalPersona中不適用於Java,MySQL
String query = "select * from employee";
try {
res = conn.getRecords(query, con);
while(res.next()) {
**System.out.println("Name : "+res.getString(1));**
Blob data1 =res.getBlob("fingerprint");
**System.out.println("Fingerprint data from DB: "+data1);**
int blobLengh=(int)data1.length();
byte data[]=data1.getBytes(1, blobLengh);
DPFPTemplate t = DPFPGlobal.getTemplateFactory().createTemplate();
t.deserialize(data);
//setTemplate(t);
System.out.println("from DB: "+t);
System.out.println("Current Finger: "+features);
DPFPVerificationResult result;
result = verificator.verify(features,t);
updateStatus(result.getFalseAcceptRate());
//System.out.println(result.isVerified());
if (result.isVerified()){
System.out.println("The fingerprint was VERIFIED.");
System.exit(0);
}
else{
System.out.println("The fingerprint was NOT VERIFIED.");
}
}
} catch (SQLException ex) {
//Logger.getLogger(AlreadyRegisteredDetails.class.getName()).log(Level.SEVERE, null, ex);
ex.printStackTrace();
}
每次我掃描了我的手指輸出來像使用
指紋識別器,掃描指紋。
名稱:從數據庫阿馬爾
指紋數據:[B @ 872ebe
名稱:從數據庫阿瑪爾
指紋數據:[B @ f029f6
名稱:阿瑪爾
來自數據庫的指紋數據:[B @ 1da6b61
名稱:從數據庫阿馬爾
指紋數據:[B @ bc2ca4
名稱:阿瑪爾從數據庫
指紋數據:[B @ 6d7f85
可能的重複[如何打印我的Java對象而不會得到「SomeType @ 2f92e0f4」?](http://stackoverflow.com/questions/29140402/how-do-i-print-my-java-object- without-getting-sometype2f92e0f4) –
顯示你的'getRecords'方法。 – zulq
public ResultSet getRecords(String query,Connection conn)throws SQLException { \t \t this.conn = conn; \t \t try { stmt = conn.createStatement(); result = stmt.executeQuery(query); (例外se){ System.out.println(「未找到Sql連接」); se.printStackTrace(); }
返回結果; } –