Code Monkey home page Code Monkey logo

fbjava's Issues

Error when calling java function inside default connection of other java function

Example:

public static int a() {
    return 123;
}

public static int b() throws SQLException {
    Connection con = DriverManager.getConnection("jdbc:default:connection:");
    PreparedStatement pstmt = con.prepareStatement("select a() from rdb$database");
    ResultSet rs = pstmt.executeQuery();
    rs.next();
    return rs.getInt(1);
}
create function a() returns int external name 'a()' engine java;
create function b() returns int external name 'b()' engine java;
commit;

select b() from rdb$database;

Both functions share same InternalContext, so after closing context from first function, second fails with error:


           B 
============ 
Statement failed, SQLSTATE = HY000
java.lang.NullPointerException
	at org.firebirdsql.fbjava.impl.InternalContext.close(InternalContext.java:152)
	at org.firebirdsql.fbjava.impl.ExternalFunction.execute(ExternalFunction.java:74)
	at org.firebirdsql.fbjava.impl.FbClientLibrary$IExternalFunction$VTable$2.invoke(FbClientLibrary.java:9580)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback(CallbackReference.java:485)
	at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback(CallbackReference.java:515)

-At function 'B'
After line 0 in file test.sql

Slow blob fetch into java procedure

in DB:

create or alter procedure java_split (
  dummy blob SUB_TYPE TEXT,
  delimiter varchar(10)
) returns (item varchar(60))
  external name 'org.firebirdsql.fbjava.examples.fbjava_example.FbSplit.split()'
  engine java;

Java:

public class FbSplit {
    public static ExternalResultSet split() throws Exception {
        final ProcedureContext context = ProcedureContext.get();
        return new ExternalResultSet() {
            ValuesMetadata outMetadata = context.getOutputMetadata();
            Values outValues = context.getOutputValues();
            Values inputValues = context.getInputValues();

            String[] items_list = null;
            int item_index;

            @Override
            public boolean fetch() throws Exception {
                if (items_list == null) {
                    java.lang.Object blob_object = inputValues.getObject(1);

//                    FBBlob blob = (FBBlob) blob_object;
                    java.sql.Blob blob = (java.sql.Blob) blob_object;

                    byte[] bytes_data = blob.getBytes(1, (int) (blob.length())); // TO SLOW
                    String blob_string = new String(bytes_data);
                    items_list = blob_string.split(inputValues.getObject(2).toString());
                }
                if (item_index < items_list.length) {
                    outValues.setObject(1, items_list[item_index]);

                    item_index++;
                    return true;
                }
                return false;

            }
        };
    }
}

then call

select * from java_split(6 000 000 characters length blob, ',')

40 sec execution time
but if I call from standalone java application ~1-2 sec

env:
java 8
jaybird 2.2.10

Make --username and --password required in deployer

The username and password are optional in deployer, consider making them required (or at minimum display a warning when left off). I was trying to install fbjava, and I had made a typo in the --password option (I typed --pasword instead) and it took me a while to notice that typo ;).

Error when restoring database with java external function

Database with single external java function can not be restored. Not sure if it engine's or plugin's problem.

/opt/firebird/bin/gbak -user sysdba -password masterkey -rep /tmp/x.fbk localhost:/tmp/x_rest.fdb                                                              /workspace/fbjava
gbak: ERROR:java.lang.RuntimeException: java.sql.SQLException: database /tmp/x_rest.fdb shutdown [SQLState:HY000, ISC error code:335544528]
	at org.firebirdsql.fbjava.impl.ExternalEngine.lambda$open$3(ExternalEngine.java:1091)
	at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
	at org.firebirdsql.fbjava.impl.ExternalEngine.open(ExternalEngine.java:1084)
	at org.firebirdsql.fbjava.impl.FbClientLibrary$IExternalEngine$VTable$1.invoke(FbClientLibrary.java:10228)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback(CallbackReference.java:485)
	at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback(CallbackReference.java:515)
Caused by: java.sql.SQLException: database /tmp/x_re...
gbak:Exiting before completion due to errors

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.