0

Java でデジタル ペルソナ SDK を使用して、テンプレートと機能セットを比較するための SOAP Web サービス メソッドを作成しています。データベース内の文字列であるテンプレートを取得し、それをバイト配列に変換して、機能セットとの照合を行う必要があります。Web メソッドの入力パラメーターは、email と ftSet で、どちらも文字列です。ftset もバイト配列に変換する必要があります。これらは try catch ブロックの後に行われます。「dbTemplate」という名前の変数にアクセスするにはどうすればよいですか?

@WebMethod(operationName = "CheckTemplate")
public String CheckTemplate(@WebParam(name = "email") String email,
        @WebParam(name = "ftSet") String ftSet) {

    Connection con = null;
    try {
        Class.forName("com.mysql.jdbc.Driver");
        con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb", "root", "1234");
        PreparedStatement st;
        st = con.prepareStatement("select template from Tbl_reg where email = ? ");
        st.setString(1, email);

        ResultSet result = st.executeQuery();

        if (result.next()) { //.next() returns true if there is a next row returned by the query.

            String dbTemplate = result.getString("template");


        }
    } catch (Exception e) {
        System.out.println(e.getMessage());

    } finally {
        if (con != null) {
            try {
                con.close();

            } catch (SQLException e) {
            }
        }
    }


            byte[] byteArray = new byte[1];
//dbTemplate is underlined here, cannot access it from the try catch
            byteArray = hexStringToByteArray(dbTemplate);
            DPFPTemplate template = DPFPGlobal.getTemplateFactory().createTemplate();
            template.deserialize(byteArray);


            byte[] fsArray = new byte[1];
            fsArray = hexStringToByteArray(ftSet);
            DPFPSample sample = DPFPGlobal.getSampleFactory().createSample();
            sample.deserialize(fsArray);

            DPFPFeatureSet features = extractFeatures(sample, DPFPDataPurpose.DATA_PURPOSE_VERIFICATION);


            DPFPVerification matcher = DPFPGlobal.getVerificationFactory().createVerification();
            DPFPVerificationResult result1 = matcher.verify(features, template);

            if (result1.isVerified()) {

                return "The fingerprint was VERIFIED.";

            } else {
                return "The fingerprint was NOT VERIFIED.";

            }  

}
4

1 に答える 1

1

Connection オブジェクトを宣言した後に、dbTemplate を宣言します。コードでは、dbTemplate は try ブロック内で宣言されているため、try ブロックの後のものはそれが何を意味するのかわかりません。

Connection con = null;
String dbTemplate = null;

この「if」ブロック以外の誰も、dbTemplate が何であるかを知りません。

if (result.next()) { //.next() returns true if there is a next row returned by the query.
    String dbTemplate = result.getString("template");
}
于 2012-11-08T04:45:02.810 に答える