pl/sql中相关java函数的定义

问题描述 投票:0回答:1

我正在尝试在 pl/sql 中使用指纹设备。我能够将指纹保存在Oracle数据库中,现在我想识别这个指纹。为此,制造商向我提供了我想要使用其Java代码的sdk。为此,我写了一段Java代码如下:

import java.sql.*;
import oracle.jdbc.*;
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;
import com.futronic.SDKHelper.*;
import java.util.Base64;
import java.util.Vector;


public class MainForm 
{

    public static String OnGetBaseTemplateComplete(String FPtemplate)
    {
        StringBuffer szMessage = new StringBuffer();
        
        String StrTemplate = FPtemplate;
        byte[] DecodeTemplate = Base64.getDecoder().decode(StrTemplate);
        m_Operation = new FutronicIdentification();
        ((FutronicIdentification) m_Operation).Farn(245);
        ((FutronicIdentification) m_Operation).BaseTemplate(DecodeTemplate);    
        

            Vector<DbRecord> Users = (Vector<DbRecord>)m_OperationObj;
            FtrIdentifyRecord[] rgRecords = new FtrIdentifyRecord[ Users.size() ];
            for( int iUsers = 0; iUsers < Users.size(); iUsers++ )
                rgRecords[iUsers] = Users.get( iUsers ).getFtrIdentifyRecord();

            FtrIdentifyResult result = new FtrIdentifyResult();
            
            int nResult = ((FutronicIdentification)m_Operation).Identification(rgRecords, result);
            if (nResult == FutronicSdkBase.RETCODE_OK)
            {
                szMessage.append("Identification process complete. User: ");
                if( result.m_Index != -1 )
                    szMessage.append(Users.get( result.m_Index ).getUserName() );
                else
                    szMessage.append("not found");
            } else {
                szMessage.append( "Identification failed." );
                szMessage.append( FutronicSdkBase.SdkRetCode2Message( nResult ) );
            }

        
        String StrMessage = szMessage.toString();
        
        return StrMessage;

    }


    /**
     * Contain reference for current operation object
     */
    private FutronicSdkBase m_Operation;
    

    private Object m_OperationObj;       
}

但问题在于其他 Java 文件中定义的函数,我不知道如何为 PL/SQL 定义此绑定。例如代码

FtrIdentifyResult result = new FtrIdentifyResult();

(FtrIdentifyResult)本身是一个单独的Java文件,有函数并且这个函数也被定义了。 (FutronicIdentification)(识别) 还有......还有。

或排队

private FutronicSdkBase m_Operation

定义了(FutronicSdkBase)类型的变量,其中(FutronicSdkBase)是一个带有函数的单独Java文件。现在我如何为 pl/sql 定义它?

java oracle plsql oracle-apex
1个回答
0
投票

您有一个与指纹设备 SDK 交互的 Java 代码片段。现在您想在 PL/SQL 中使用此 Java 代码,这可能有点棘手。这是一个细分:

Java Code Explanation: Your Java code appears to handle the processing of fingerprint templates. It decodes a Base64-encoded template, performs some operations using the Futronic SDK, and attempts to identify a user based on the fingerprint data.

Integration Challenge: The challenge here is that your Java code relies on classes and methods from external libraries (Futronic SDK), and you're not sure how to make this work in PL/SQL.

Integration Steps:

    Java Class: Your Java code should be encapsulated within a Java class, which we'll call "FingerprintProcessor" for this example.

    Java Methods: Each operation or function you want to perform from PL/SQL should be a public method within the "FingerprintProcessor" class. For instance, you might have a method like identifyUser(byte[] fingerprintData).

    Oracle Integration: You'll need to compile this Java class into a .jar file and load it into Oracle using the loadjava utility.

    Java Stored Procedure: Next, you'll create a Java Stored Procedure in Oracle that serves as a wrapper for your Java methods. This stored procedure will be callable from PL/SQL. For example:

创建或替换过程IdentifyUser(fingerprintData BLOB, result OUT VARCHAR2) AS 语言 爪哇 NAME 'FingerprintProcessor.identifyUser(byte[], java.lang.String[])'; 此 PL/SQL 过程将指纹数据作为输入,并在输出参数中返回结果。

PL/SQL: Finally, you can call this PL/SQL procedure from your PL/SQL code, passing the necessary parameters.

处理依赖关系:确保任何外部依赖关系(例如 Futronic SDK)在您的 Oracle 环境中可用并正确配置。

错误处理:记住要优雅地处理异常和错误,因为 PL/SQL 和 Java 有不同的异常处理机制。

测试和调试:测试对于确保集成按预期工作至关重要。您可能需要对集成过程中出现的任何问题进行故障排除和调试。

© www.soinside.com 2019 - 2024. All rights reserved.