1
I’m developing a biometric system to register and identify customers. I am basing myself on Veridis Biometric only that when requesting identification it is generating this error:
The format is not supported, invalid or could not be determined Automatically (Error #-9)
Searching for the database fingerprints it always gives this error and can not solve this problem.
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;
import javax.sound.sampled.AudioFormat.Encoding;
import veridis.biometric.BiometricIdentification;
import veridis.biometric.BiometricSDK;
import veridis.biometric.BiometricTemplate;
import veridis.biometric.samples.applet.Base64;
import veridis.biometric.BiometricImage;
import veridis.biometric.BiometricTemplate;
import veridis.biometric.BiometricException.FeatureNotAvailableForFreeException;
import veridis.biometric.BiometricException.FeatureNotLicensedException;
import veridis.biometric.BiometricException.UnsupportedBiometricModalityException;
import veridis.sample.util.ButtonLayout;
import org.json.*;
public class dbAccess {
private static final BiometricTemplate AddTemplate = null;
protected static Connection con = null;
protected static Statement stm = null;
protected static int minimumThreshold = 40;
public static Object Console;
public static boolean AddTemplate(BiometricTemplate template) throws SQLException {
String str = "http://192.168.51.199/ponto/index.php/JSON/listaTemplate/";
try {
URL url = new URL(str);
Scanner scan;
try {
scan = new Scanner(url.openStream());
String str2 = new String();
while (scan.hasNext()) {
str2 += scan.nextLine();
}
scan.close();
JSONObject obj = new JSONObject(str2);
JSONArray elenco = obj.getJSONArray("usuarios");
for (int i = 0; i < elenco.length(); i++) {
String[] tmp = elenco.getString(i).split("-");
BiometricTemplate tempBD;
try {
tempBD = new BiometricTemplate((Base64.decode(tmp[1])));
System.out.println(template.getData());
System.out.println(Base64.decode(tmp[1]));
Object bytes = template;
System.out.println("Text [Byte Format] : " + bytes);
if (tempBD.match(tempBD) > minimumThreshold) {
System.out.println("Achou");
return true;
}
} catch (Exception e) {
System.out.println(e.getLocalizedMessage());
return false;
}
//System.out.println(spl[0]);
//usersmodel.addElement(elenco.getString(i));
}
} catch (MalformedURLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
/*if(res.next()){
try{
BiometricTemplate tempBD = new BiometricTemplate((Base64.decode(res.getString("template"))));
if (tempBD.match(template) > minimumThreshold)
return 1;
}
catch(Exception e ){
System.out.println(e.getLocalizedMessage());
return -1;
}*/
System.exit(0);
return true;
}
/*Function to get Template from database*/
public static BiometricTemplate getTemplate(BiometricTemplate template, String id) throws SQLException {
if (con == null) {
connectToDB();
}
if (stm == null) {
stm = con.createStatement();
}
String query = "SELECT * FROM usuarios where id = \"" + id + "\"";
ResultSet res = stm.executeQuery(query);
if (res.next()) {
try {
BiometricTemplate tempBD = new BiometricTemplate((Base64.decode(res.getString("Template"))));
return tempBD;
} catch (Exception e) {
System.out.println(e.getLocalizedMessage());
return null;
}
}
return null;
}
/*Function to verify if the given template matches with the template corresponding to the given id*/
public static int verificaIdentificador(BiometricTemplate template, String id) throws SQLException {
ResultSet res = stm.executeQuery(id);
if (res.next()) {
try {
BiometricTemplate tempBD = new BiometricTemplate((Base64.decode(res.getString("template"))));
if (tempBD.match(template) > minimumThreshold) {
return 1;
}
} catch (Exception e) {
System.out.println(e.getLocalizedMessage());
return -1;
}
}
return 0;
}
/*Given a ID, tries to find correspondent template*/
public static String findIDTemplate(BiometricTemplate template) throws SQLException {
if (con == null) {
connectToDB();
}
if (stm == null) {
stm = con.createStatement();
}
String query = "SELECT * FROM usuarios";
ResultSet res = stm.executeQuery(query);
/*prepares identification context to perform match faster*/
BiometricIdentification temp = new BiometricIdentification(template);
while (res.next()) {
try {
//retrieves template
BiometricTemplate tempBD = new BiometricTemplate((Base64.decode(res.getString("Template"))));
//checks if match score is higher than minimum threshold
if (temp.match(tempBD) > 40) {
return res.getString("id");
}
} catch (Exception e) {
System.out.println(e.getLocalizedMessage());
return null;
}
}
return null;
}
public static void main(String[] args) {
dbAccess.connectToDB();
}
public static void connectToDB() {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver");
String userName = "root";
String password = "12rafael34";
String url = "jdbc:mysql://192.168.51.199//";
String dbName = "survey";
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(url + dbName, userName, password);
stm = con.createStatement();
stm.executeUpdate("DROP TABLE IF EXISTS template");
stm.executeUpdate("CREATE TABLE template ("
+ "id varchar(100) PRIMARY KEY NOT NULL,"
+ "template varchar(1000) NOT NULL,"
+ "nome varchar(1000) NOT NULL);");
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
public static BiometricTemplate getAddtemplate() {
return AddTemplate;
}
}
This error occurs at what point exactly? In the code you shared the
main
just calls theconnectToDB()
, which in turn only seems to try to create the bank.– Romulo