rave rave - 1 year ago 145
Java Question

Save a fingerprint template into a database mysql - java

I am developing a project with the sdk fingerprint of Griaule , and as a start I'm creating a program without a GUI that allows the user to scan his fingerprint and store it in a mysql database already created earlier.
I'm here to ask you a hand with regard to storing the fingerprint in the database.
In the program I created, I captured the fingerprint, I extracted the template from the fingerprint through a function I call extract () .
After that I should call another function , enroll (), which allows me to save the fingerprint in a database.
Even looking at the SDK examples I did not understand how it works, can someone help me? thanks in advance! :)

public void enroll() {
try {
//Inserts the template on the database
enrollStmt.setBinaryStream(1,new ByteArrayInputStream(template.getData()), template.getData().length);

//Picks the ID generated for it.
ResultSet rs = insertedIdStmt.executeQuery();
ui.writeLog("Fingerprint enrolled with id = "+Integer.toString(rs.getInt(1)));

} catch (SQLException e) {
ui.writeLog("Error enrolling template");

Answer Source

It is saving the finger print data as BLOB in the database. Blob (Binary Large Object) is nothing but a byte array representation of information, mainly used to store images etc in database. In your case, the fingerprint information is being stored.

enrollStmt.setBinaryStream(1,new ByteArrayInputStream(template.getData()), template.getData().length);

In this line, the bytearrayinputstream is created using the data in the template object. template.getData is giving you the byte[] representation of the fingerprint information. Then the byte[] is getting saved in database, by


Whereas, the following query gives you the id for the data stored, for your use.

 ResultSet rs = insertedIdStmt.executeQuery();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download