|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
stored procedure without storing jar in databaseHi!
As said in http://wiki.apache.org/db-derby/DerbySQLroutines, it is not necessary to load jar files in database to create stored procedures. If jar is in application classpath it is enought. But I have a trouble when I try to call my stored procedure from ij. So I try this: 1. Write java class test.MyClass with method public static void testMethod(int p1, int p2) 2. Compile storedprocs.jar with MyClass inside 3. Create stored proc in database CREATE PROCEDURE testProc(IN KW1 INTEGER, IN KW2 INTEGER) PARAMETER STYLE JAVA MODIFIES SQL DATA LANGUAGE JAVA DYNAMIC RESULT SETS 0 EXTERNAL NAME 'test.MyClass.testMethod'; 4. start ij with the script @echo off if defined DERBY_HOME ( SET CLASSPATH=C:\projects\storedprocs.jar sysinfo -cp embedded test.MyClass.class java -Dclasspath=%CLASSPATH% -Dij.connection.mydb=jdbc:derby:mydb" -jar "%DERBY_HOME%\lib\derbyrun.jar" ij ) else ( ECHO DERBY_HOME is not defined! ) sysinfo -cp embedded test.MyClass.class tells me that MyClass is in classpath. but when I try to call procedure I get an exception > > > > > ERROR 42X51: The class 'test.MyClass' does not exist or is inaccessible. This can happen if the class is not public. ERROR XJ001: Java exception: 'test.MyClass: java.lang.ClassNotFoundException'. So the question is in that how create stored procedure without storing jar in database. Thanks! -- King regards, Vitalik |
|
|
Re: stored procedure without storing jar in databaseHi Vitalik,
I think that the -jar switch may be overriding the -cp switch. This is what the tool documentation for the -jar switch says: "When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored." Try wiring the Derby jars into your CLASSPATH and boot the vm with the -cp switch but not the -jar switch. Hope this helps, -Rick Vitalik wrote: > Hi! > > As said in http://wiki.apache.org/db-derby/DerbySQLroutines, it is not > necessary to load jar files in database to create stored procedures. > If jar is in application classpath it is enought. But I have a trouble > when I try to call my stored procedure from ij. > So I try this: > > 1. Write java class test.MyClass with method public static void > testMethod(int p1, int p2) > 2. Compile storedprocs.jar with MyClass inside > 3. Create stored proc in database > > CREATE PROCEDURE testProc(IN KW1 INTEGER, IN KW2 INTEGER) > PARAMETER STYLE JAVA > MODIFIES SQL DATA > LANGUAGE JAVA > DYNAMIC RESULT SETS 0 > EXTERNAL NAME 'test.MyClass.testMethod'; > > 4. start ij with the script > > @echo off > if defined DERBY_HOME ( > > SET CLASSPATH=C:\projects\storedprocs.jar > sysinfo -cp embedded test.MyClass.class > java -Dclasspath=%CLASSPATH% -Dij.connection.mydb=jdbc:derby:mydb" > -jar "%DERBY_HOME%\lib\derbyrun.jar" ij > > ) else ( > ECHO DERBY_HOME is not defined! > ) > > sysinfo -cp embedded test.MyClass.class tells me that MyClass is in classpath. > > but when I try to call procedure I get an exception > >>>>>> ERROR 42X51: The class 'test.MyClass' does not exist or is inaccessible. This can happen if the class is not public. >>>>>> > ERROR XJ001: Java exception: 'test.MyClass: java.lang.ClassNotFoundException'. > > So the question is in that how create stored procedure without storing > jar in database. > Thanks! > > |
|
|
Re: stored procedure without storing jar in databaseThank you Rick!
It seems like you are right! 2009/10/15 Rick Hillegas <Richard.Hillegas@...>: > Hi Vitalik, > > I think that the -jar switch may be overriding the -cp switch. This is what > the tool documentation for the -jar switch says: "When you use this option, > the JAR file is the source of all user classes, and other user class path > settings are ignored." Try wiring the Derby jars into your CLASSPATH and > boot the vm with the -cp switch but not the -jar switch. > > Hope this helps, > -Rick > > Vitalik wrote: >> >> Hi! >> >> As said in http://wiki.apache.org/db-derby/DerbySQLroutines, it is not >> necessary to load jar files in database to create stored procedures. >> If jar is in application classpath it is enought. But I have a trouble >> when I try to call my stored procedure from ij. >> So I try this: >> >> 1. Write java class test.MyClass with method public static void >> testMethod(int p1, int p2) >> 2. Compile storedprocs.jar with MyClass inside >> 3. Create stored proc in database >> >> CREATE PROCEDURE testProc(IN KW1 INTEGER, IN KW2 INTEGER) >> PARAMETER STYLE JAVA >> MODIFIES SQL DATA >> LANGUAGE JAVA >> DYNAMIC RESULT SETS 0 >> EXTERNAL NAME 'test.MyClass.testMethod'; >> >> 4. start ij with the script >> >> @echo off >> if defined DERBY_HOME ( >> >> SET CLASSPATH=C:\projects\storedprocs.jar >> sysinfo -cp embedded test.MyClass.class >> java -Dclasspath=%CLASSPATH% -Dij.connection.mydb=jdbc:derby:mydb" >> -jar "%DERBY_HOME%\lib\derbyrun.jar" ij >> >> ) else ( >> ECHO DERBY_HOME is not defined! >> ) >> >> sysinfo -cp embedded test.MyClass.class tells me that MyClass is in >> classpath. >> >> but when I try to call procedure I get an exception >> >>>>>>> >>>>>>> ERROR 42X51: The class 'test.MyClass' does not exist or is >>>>>>> inaccessible. This can happen if the class is not public. >>>>>>> >> >> ERROR XJ001: Java exception: 'test.MyClass: >> java.lang.ClassNotFoundException'. >> >> So the question is in that how create stored procedure without storing >> jar in database. >> Thanks! >> >> > > -- King regards, Vitalik |
| Free embeddable forum powered by Nabble | Forum Help |