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] 
<[email protected]>
À : philippe02 <[email protected]> 
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.

Reply via email to