开发者

Oracle java stored procedure

I'm trying to make a Java Stored Procedure in Oracle 11g which retrieve Google Analytics information.

Working on this for three days now, but without success. Here is step by step what I did:

Uploaded the 5 required JAR files, here link, to the database using:

loadjava -user scott/tiger@WH01 gdata-analytics-2.1.jar

Then i created java source file (in pl/sql developer IDE) and used the example code in the link above. Compiled it (f8) and it 开发者_运维问答appeared in the Java Classes Tree (same for the classes created with the jar files).

After I wrote the procedure to call the java class:

create or replace procedure KEVIN_PROCEDURE_ANALYTICS AS LANGUAGE JAVA NAME 'Kevin_Analytics.main(java.lang.String[])';

Finally I call the procedure:

exec KEVIN_PROCEDURE_ANALYTICS();

and i get the error:

ORA-29532: Java call terminated by uncaught Java exception: java.lang.IllegalStateException: Cannot call dirty() without holding the lock on the registry.

Using google I found this link (the java code of a class where there is a method which prints this error message exactly) and I figured that I had to use an synchronized method, please check the link and I think you will find out too.

Now the problem is, I have really no idea how and where I must put this synchronized code. If someone of you can show me this I will be really.

Thanks for reading this post, please, if someone can help me, it will be greatly appreciated.

Kevin Vermaat


Well, Downloading the jars and the example from the link above I loaded everything into my Oracle database and got exactly the same error. Even though the error is due to synchronization issue for sure, there is nothing I had to add. The code is the code from the example and no where in did I find a direct usage of a "registryBuilder" object any object from the class.

well, It will get long to write everything in Detail. so I will write the steps I performed to overcome various errors encountered while loading the jars and running the code. maybe performing the same steps will solve the issue for you too.

1- give grants to the user to create tables and procedures and also increase its quota on users table space. I will try to use data provided by you for user and database. to give grants, connect as sysdba:

  sqlplus sys/password@WH01 as sysdba 

after you are connected, give grants to user scott and increase its quota:

  grant create any table to scott;

  grant create any procedure to scott;

  alter user scott quota unlimited on users;

(and please consult your DBA regarding the above as it might not be suitable to give unlimited grants like I did out of laziness)

2- now load the files again. I load all 5 jars at once. also, add option -f and -genmissing to your command as without them it did not work:

loadjava -genmissing -f -user scott/tiger@WH01 gdata-analytics-2.1.jar gdata-analytics-meta-2.1.jar gdata-core-1.0.jar google-collect-1.0-rc1.jar jsr305.jar

this is what I did to make it run for me.


From the javadoc to the method you found:

 /**
   * Dirty this builder.  Whoever is modifying this builder must also hold
   * onto this builder's lock while modifying it, by using a
   * {@code sychronized(registryBuilder) ...} block, or this method will throw
   * an {@link IllegalStateException}.
   */

It says you must have a lock on the builders lock, by having it inside a synchronized(registryBuilder) {....} block. Try putting that around your code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜