oracle 用Java在PL/SQL中实现指纹设备

qojgxg4l  于 2023-10-16  发布在  Oracle
关注(0)|答案(1)|浏览(97)

我正在尝试在pl/sql中使用指纹设备。我能够保存在Oracle数据库中的指纹,现在我想识别这个指纹。对于这一点,制造商已经为我提供了sdk,我想使用它的Java代码。为此,我写了一段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 and Identification and. also.
或成直线

private FutronicSdkBase m_Operation

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

wfypjpf4

wfypjpf41#

您需要:

  • 在Java中,long是数值数据类型,但在Oracle中,LONG是(遗留)文本数据类型;所以在Oracle函数中,你希望NUMBER而不是LONG作为数据类型。
  • 最后一个参数和返回类型应该是java.lang.String(注意大写字母)而不是string

就像这样:

CREATE AND COMPILE JAVA SOURCE NAMED IdentifyFutronic AS
public class FPIdentifyFutronic {
    public static String FPIdentify(
      long FPtemplate,
      long T1,
      long T2,
      long T3,
      String username
    ) {
        return "Do stuff";
    }
}

然后又道:

CREATE OR REPLACE FUNCTION identify_FP (
  FPtemplate NUMBER,
  T1         NUMBER,
  T2         NUMBER,
  T3         NUMBER,
  username   VARCHAR2
) RETURN VARCHAR2
  AS LANGUAGE JAVA NAME
    'FPIdentifyFutronic.FPIdentify(
      long,
      long,
      long,
      long,
      java.lang.String
    ) return java.lang.String';
/

然后又道:

declare
  vOut varchar2(4000);
begin
  vOut := identify_FP(1, 2, 3, 4, 'testjs5');
  dbms_output.put_line(vOut);
end;
/

输出:

Do stuff

fiddle

相关问题