on 10-27-2015 7:17 AM
I get the following error when I run JAVA function:
=============================================
The following error occurred while fetching results:
Procedure 'hello' terminated with unhandled exception
'java.lang.Security Exception: File I/O not allowed'
SQLCODE=-91, ODBC 3 State='HY000"
=============================================
[OS Environment]
* Linux testsvr 2.6.9-89.EL #1 Mon Apr 20 10:22:29 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
* Java -version : java version "1.4.2_11"
* Sybase Server Version : 12.7.0/ESD 12
[Java Source Code]
import java.io.FileInputStream;
public class Dummy {
public static String hello(String str) throws Exception {
FileInputStream fis = null;
try {
fis = new FileInputStream("/app/sybase/Test/test.txt");
fis.read();
return str;
} catch (Exception e) {
throw e;
} finally {
if (fis != null) {
try {
fis.close();
} catch (Exception e) {}
}
}
}
}
Function SQL
[SQL Statements]
Install java new from file '/app/sybase/Test/Dummy.class';
Create function testdummy(in name varchar(249)) returns varchar(255) external name 'Dummy.hello(Ljava/lang/String;)Ljava/lang/String;' language JAVA;
Select testdummy('abc');
Permission was granted permission from the top 777.
Any help would be really appreciated.
Thank you.
Hi Lee,
Does the function fail when called by its owner?
If it fails only when called with different user then try recreate it with option "SQL SECURITY INVOKER"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try a function that does not use IO.
Can you also try this on a current IQ? 12.7 is very old and you are using a JVM that is deprecated. There used to be restrictions in ASE and IQ Java that prevented IO to console and elsewhere so the JVM could run 'headless' without getting hung waiting for user input and resolution.
Perhaps you are hitting that restriction, even though the documentation may state otherwise and file IO is allowed. Running on a current IQ version will help to narrow this down.
Chris
Looking in google with "java.lang.Security Exception", this looks like a security restriction on JVM !
Do you get same problem when executing the Dummy.class outside IQ database?
By the way, your test case works fine in my IQ 16 Linux. I cannot test it in IQ12.7 because my Jdk compiler is not compatible with this old IQ version.
Regards,
Tayeb.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.