You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by philippe02 <ju...@yahoo.fr> on 2013/04/15 19:51:51 UTC

Problem to use java classes in Derby

Hello

 I have the same problem as below 
 
http://apache-database.10148.n7.nabble.com/Problems-create-SQL-Function-td106464.html. 

I have the same problem and I can't resolve it. I looked in forums, Google
etc for many long time and I have always the same message.
ERROR 42X51: The class 'Myclass' does not exist or is inaccessible. This can
happen if the class is not public.

All in my class is Public and I tried many samples for the same result....

I want to copy rows from Derby tables to SQL server via a trigger "after
insert". I created a class that works properly with eclipse and JDBC. I
can't insert this class in Derby.

Could you help me ?

Thanks

Philippe 




--
View this message in context: http://apache-database.10148.n7.nabble.com/Problem-to-use-java-classes-in-Derby-tp129202.html
Sent from the Apache Derby Developers mailing list archive at Nabble.com.

Re: Problem to use java classes in Derby

Posted by Knut Anders Hatlen <kn...@oracle.com>.
philippe02 <ju...@yahoo.fr> writes:

> Hi Knut
> Tanks for your help
> I tried with all In upper case , all in lower case it doesn't work ...

Are you using embedded Derby or client/server?

How did you make the class available to Derby? (Did you put it on the
application's classpath, or did you put it in a jar file that you
installed in the database with SQLJ.INSTALL_JAR?)

-- 
Knut Anders

Re: Problem to use java classes in Derby

Posted by philippe02 <ju...@yahoo.fr>.

Hi Knut
Tanks for your help
I tried with all In upper case , all in lower case  it doesn't work ...

Regards
Philippe 

Le 18 avr. 2013 à 12:06, "Knut Anders Hatlen-5 [via Apache Database]" <ml...@n7.nabble.com> a écrit :

> philippe02 <[hidden email]> writes: 
> 
> > Hi Rick 
> > Thanks for your message. 
> > Here is my function 
> > CREATE function CopyUserdata( 
> > ID int , 
> > MACHINE int , 
> > JOB varchar(50) , 
> > RECEIVED varchar(50) , 
> > FIELD varchar(50) , 
> > VALUE varchar(255) , 
> > STANDARD int) 
> > returns int 
> > LANGUAGE JAVA 
> > PARAMETER STYLE JAVA 
> > NO SQL 
> > EXTERNAL NAME 'sendTOSQLserver.RecordToUserdata'; 
> > My Java code 
> > import java.sql.Connection; 
> > import java.sql.DriverManager; 
> > import java.sql.Statement; 
> > public class sendTOSQLSERVER {
> 
> Hi Philippe, 
> 
> It looks like the Java class name doesn't match the name used in the 
> EXTERNAL NAME clause of the CREATE FUNCTION statement (sendTOSQLSERVER 
> vs sendTOSQLserver). It might work better if they match. Note that case 
> differences are significant in Java class names. 
> 
> Hope this helps, 
> 
> -- 
> Knut Anders 
> 
> 
> If you reply to this email, your message will be added to the discussion below:
> http://apache-database.10148.n7.nabble.com/Problem-to-use-java-classes-in-Derby-tp129202p129423.html
> To unsubscribe from Problem to use java classes in Derby, click here.
> NAML




--
View this message in context: http://apache-database.10148.n7.nabble.com/Problem-to-use-java-classes-in-Derby-tp129202p129424.html
Sent from the Apache Derby Developers mailing list archive at Nabble.com.

Re: Problem to use java classes in Derby

Posted by Knut Anders Hatlen <kn...@oracle.com>.
philippe02 <ju...@yahoo.fr> writes:

> Hi Rick
> Thanks for your message.
> Here is my function
> CREATE function CopyUserdata(
> ID int ,
> MACHINE int ,
> JOB varchar(50) ,
> RECEIVED varchar(50) ,
> FIELD varchar(50) ,
> VALUE varchar(255) ,
> STANDARD int)
> returns int
> LANGUAGE JAVA
> PARAMETER STYLE JAVA
> NO SQL
> EXTERNAL NAME 'sendTOSQLserver.RecordToUserdata';
> My Java code
> import java.sql.Connection;
> import java.sql.DriverManager;
> import java.sql.Statement;
> public class sendTOSQLSERVER {

Hi Philippe,

It looks like the Java class name doesn't match the name used in the
EXTERNAL NAME clause of the CREATE FUNCTION statement (sendTOSQLSERVER
vs sendTOSQLserver). It might work better if they match. Note that case
differences are significant in Java class names.

Hope this helps,

-- 
Knut Anders

Re: Problem to use java classes in Derby

Posted by philippe02 <ju...@yahoo.fr>.
Hi Rick
 
Thanks for your message.
 
Here is my function
 
CREATE  function CopyUserdata(
    ID int ,
 MACHINE int ,
 JOB varchar(50) ,
 RECEIVED varchar(50)  ,
 FIELD varchar(50) ,
 VALUE varchar(255) ,
 STANDARD int)
     returns int
    LANGUAGE JAVA
    PARAMETER STYLE JAVA
    NO SQL
    EXTERNAL NAME 'sendTOSQLserver.RecordToUserdata';
 
My Java code
 
 importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.Statement;publicclasssendTOSQLSERVER {publicstaticvoidmain(String[] args) throwsException {intID = 1; // args[0]; intMACHINE = 2; //args[1];String JOB = "Monjob"; //args[2];String RECEIVED = "3"; //args[3];String FIELD = "Ma valeur"; //args[4];String VALUE = "4"; //args[5];intSTANDARD = 1; // args[6];// String ID = args[0]; // String MACHINE = args[1];// String JOB = args[2];// String RECEIVED = args[3];// String FIELD = args[4];// String VALUE = args[5];// String STANDARD =args[6];RecordToUserdata(ID,MACHINE,JOB,RECEIVED,FIELD,VALUE,STANDARD);
}
String JOBID,String USERID, String MACHID, String VERSION, String JOBUID,Integer RECNR,String JOBSRC, String CHNTYPE,
String RCV, String SRCLOC ,Integer SRCPG, String SRCTYPE , String SRCWTH , 
String PRCTYPE ,String PRCCMPLT,String DLV , Integer OUTPG, String MEDTYPE , String MEDSPC,String MEDWGT ,
String MEDSRC ,String FOLD , String BIND ,String MEDDST ,String FILETYPE,String FILECMPR, Integer FILESZ,String FILEDST,
Integer RESX, Integer RESY, Integer CMPID, String COLMOD, String QUALMOD, String CONTMOD,String ORIGTYPE,Integer JOBINT,Integer EXPORTABLE,
String USERNAME, 
String PRTJOBID,Integer JOBCOPIES,Integer OUTSET,String JOBCMPLT)
{publicstaticintRecordToPlcdata(Integer ID,String UID,Integer MACHINE,String LASTDELIVERED,Integer RECTYPE, String ACCID, longSRCHGT, longSRCAREA,longOUTWTH,longOUTHGT ,longOUTAREA , Integer WTHSCL, Integer HGTSCL,String MIRROR, Integer ROT ,longCOLBLACK,longCOLCYAN, longCOLMAGENTA,longCOLYELLOW, longCOLBLACKCLICKS, longCOLCOLORCLICKS,String JOBNR,try{
String mystringSQL = 
connectSQLServer(mystringSQL);
}
{
}
}"INSERT INTO FromDerby VALUES("+ ID + ",'"+ UID + "',"+ MACHINE + ",'"+ LASTDELIVERED + "','"+ RECTYPE + "','"+ ACCID + "',"+ JOBID + "','"+ USERID + ",'"+ MACHID + "','"+ VERSION + "','"+ JOBUID + "',"+ RECNR + ",'"+ JOBSRC + "','"+ CHNTYPE + "','"+ RCV + "','"+ SRCLOC + "',"+ SRCPG + ",'"+ SRCTYPE + "',"+ SRCWTH + ","+ SRCHGT + ","+ SRCAREA + ","+ OUTWTH + ","+ OUTHGT + ","+ OUTAREA + ","+ WTHSCL + ","+ HGTSCL + ",'"+ MIRROR + "',"+ ROT + ",'"+ PRCTYPE + "','"+ PRCCMPLT + "','"+ DLV + "',"+ OUTPG + ",'"+ MEDTYPE + "','"+ MEDSPC + "','"+ MEDWGT + "','"+ MEDSRC + "','"+ FOLD + "','"+ BIND + "','"+ MEDDST + "','"+ FILETYPE + "','"+ FILECMPR + ","+ FILESZ + ",'"+ FILEDST + "',"+ RESX + ","+ RESY + ","+ CMPID + ",'"+ COLMOD + "','"+ QUALMOD + "','"+ CONTMOD + "','"+ ORIGTYPE + "',"+ JOBINT + ","+ EXPORTABLE + ",'"+ USERNAME + "',"+ COLBLACK + ","+ COLCYAN + ","+ COLMAGENTA + ","+ COLYELLOW + ","+ COLBLACKCLICKS + ","+ COLCOLORCLICKS + ",'"+ JOBNR + "','"+
 PRTJOBID + "',"+ JOBCOPIES + ","+ OUTSET + ",'"+ JOBCMPLT + "')"; catch(Exception except)return1; publicstaticvoidconnectSQLServer(String mystringSQL) {try{
Class.forName(
Connection connection = DriverManager 
.getConnection( "com.microsoft.sqlserver.jdbc.SQLServerDriver"); // "jdbc:sqlserver://127.0.0.1;databaseName=PLCDATA;integratedSecurity=true;"); Statement statement = connection.createStatement(); 
statement.execute(mystringSQL); 
connection.close();
}
{
except.printStackTrace();
}
}
{
String mystringSQL = 
System.
connectSQLServer(mystringSQL);
} 
}"jdbc:sqlserver://localhost\\SQLEXPRESS;databaseName=accderby;integratedSecurity=true;"); catch(Exception except)publicstaticintRecordToUserdata(intID, intMACHINE, String JOB , String RECEIVED, String FIELD, String VALUE, intSTANDARD)"INSERT INTO USERDATA VALUES("+ ID + ","+ MACHINE + ",'"+ JOB + "','"+ RECEIVED + "','"+ FIELD + "','"+ VALUE + "',"+ STANDARD + ")";out.println(mystringSQL);return1;
 
Then I do this
CALL sqlj.INSTALL_JAR('C:\java\derby-10.8.3\lib\sendTOSQLserver.jar', APP.sendTOSQLserver', 0);
CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.database.classpath', APP.sendTOSQLserver');
 
Thank you for your help
 
Philippe
 
 
 

De : Rick Hillegas [via Apache Database] <ml...@n7.nabble.com>
À : philippe02 <ju...@yahoo.fr> 
Envoyé le : Mercredi 17 avril 2013 19h50
Objet : Re: Problem to use java classes in Derby



On 4/15/13 10:51 AM, philippe02 wrote: 
> Hello 
> 
>   I have the same problem as below 
> 
> http://apache-database.10148.n7.nabble.com/Problems-create-SQL-Function-td106464.html. 
Hi Philippe, 

That error message covers a lot of problems. The email thread you 
referenced shows that the user's code had to be corrected in several 
ways. We might be able to give better advice if you could include your 
CREATE FUNCTION statement and the signature of your public static Java 
method. 

Thanks, 
-Rick 

> I have the same problem and I can't resolve it. I looked in forums, Google 
> etc for many long time and I have always the same message. 
> ERROR 42X51: The class 'Myclass' does not exist or is inaccessible. This can 
> happen if the class is not public. 
> 
> All in my class is Public and I tried many samples for the same result.... 
> 
> I want to copy rows from Derby tables to SQL server via a trigger "after 
> insert". I created a class that works properly with eclipse and JDBC. I 
> can't insert this class in Derby. 
> 
> Could you help me ? 
> 
> Thanks 
> 
> Philippe 
> 
> 
> 
> 
> -- 
> View this message in context: http://apache-database.10148.n7.nabble.com/Problem-to-use-java-classes-in-Derby-tp129202.html
> Sent from the Apache Derby Developers mailing list archive at Nabble.com. 
> 



If you reply to this email, your message will be added to the discussion below:http://apache-database.10148.n7.nabble.com/Problem-to-use-java-classes-in-Derby-tp129202p129394.html 
To unsubscribe from Problem to use java classes in Derby, click here.
NAML



--
View this message in context: http://apache-database.10148.n7.nabble.com/Problem-to-use-java-classes-in-Derby-tp129202p129401.html
Sent from the Apache Derby Developers mailing list archive at Nabble.com.

Re: Problem to use java classes in Derby

Posted by Rick Hillegas <ri...@oracle.com>.
On 4/15/13 10:51 AM, philippe02 wrote:
> Hello
>
>   I have the same problem as below
>
> http://apache-database.10148.n7.nabble.com/Problems-create-SQL-Function-td106464.html.
Hi Philippe,

That error message covers a lot of problems. The email thread you 
referenced shows that the user's code had to be corrected in several 
ways. We might be able to give better advice if you could include your 
CREATE FUNCTION statement and the signature of your public static Java 
method.

Thanks,
-Rick
> I have the same problem and I can't resolve it. I looked in forums, Google
> etc for many long time and I have always the same message.
> ERROR 42X51: The class 'Myclass' does not exist or is inaccessible. This can
> happen if the class is not public.
>
> All in my class is Public and I tried many samples for the same result....
>
> I want to copy rows from Derby tables to SQL server via a trigger "after
> insert". I created a class that works properly with eclipse and JDBC. I
> can't insert this class in Derby.
>
> Could you help me ?
>
> Thanks
>
> Philippe
>
>
>
>
> --
> View this message in context: http://apache-database.10148.n7.nabble.com/Problem-to-use-java-classes-in-Derby-tp129202.html
> Sent from the Apache Derby Developers mailing list archive at Nabble.com.
>