How to modify a parameter in C++ passed from java (structure Newbie)
Hi,
I'm a brand new to Java (basically a C+ programmer). I have a C++ DLL that takes a structure as parameter from Java and I want to change (or populate) it in C++ DLL.
Here is what I'm trying...
// Java Code...
public class CSMSample
public static class MyDetails
String myName;
long myAge;
byte[] myBinaryData;
public native static long SMGetMyDetails(MyDetails myDetails);
public static void main(String[] args)
MyDetails myDetails = new MyDetails();
SMGetMyDetails(myDetails);
System.out.println("My Name is " + myDetails.myName + " and I am " + myDetails.myAge + " years old");
static
try
System.loadLibrary("SMSample"); //SMSample.DLL
catch (Exception e)
// Handle exception here ...
// C++ code
JNIEXPORT jlong JNICALL Java_CSMSample_SMGetMyDetails(
JNIEnv* env, jclass, jobject jMyDetails)
long error = 0;
// I need to modify jMyDetails here and my Java program should be able to read the changes!
return error;
}Can someone help me please!?
Thanks in advance,
John.
Hi
I'm doing the following:
// Java class...
public static class BYTE_ARRAY
public long Length;
public byte[] Data;
JNIEXPORT jlong JNICALL Java_CSMSample_SMGetCode(
JNIEnv* env, jclass, jobject jByteArrayCode)
BYTE_ARRAY Code;
Code.Length = 8;
Code.Data = new BYTE[Code.Length];
Code.Data[0] = 'a'; Code.Data[1] = 'b'; Code.Data[2] = 'c'; Code.Data[3] = 'd';
Code.Data[4] = 'e'; Code.Data[5] = 'f'; Code.Data[6] = 'g'; Code.Data[7] = '\0';
jbyteArray code_data = env->NewByteArray (Code.Length);
env->SetByteArrayRegion(code_data, 0, Code.Length, (const jbyte*) Code.Data);
jclass cls = env->GetObjectClass(jByteArrayCode);
jfieldID fid_Data = env->GetFieldID(cls, "Data", "[B");
jfieldID fid_Length = env->GetFieldID(cls, "Length", "J");
env->SetIntField(jByteArrayCode, fid_Length, Code.Length);
env->SetObjectField(jByteArrayCode, fid_Data, code_data);
}Java application gets the Length properly but the data part is garbage (When I print, it gives [B@9304b1, same text even if I change the values of Code.Data). Am I missing something?
Thanks,
John.
Similar Messages
-
How can i pass the parameter for strored procedure from java
dear all,
I am very new for stored procedure
1. I want to write the strored procedure for insert.
2. How can i pass the parameter for that procedure from java.
if any material available in internet create procedure and call procedure from java , and passing parameter to procedure from javaHi Ram,
To call the callable statement use the below sample.
stmt = conn.prepareCall("{call <procedure name>(?,?)}");
stmt.setString(1,value);//Input parameter
stmt.registerOutParameter(2,Types.BIGINT);//Output parameter
stmt.execute();
seq = (int)stmt.getLong(2);//Getting the result from the procedure. -
How get runing total but opening balance pass from form through parameter
Sir I have tow table in accbal have opening balance and in voudetail have daily transaction I need ledger report with opening balance
My report get opening balance from accbal and get befor given date balance from voudetail
Such as
For opening balance
Selelect case when dr>cr then dr-cr
When cr>dr then cr-dr
End opbal from accbal
For get balance form daily transaction
Select case when sum(debit)-sum(credit)> sum(credit)-sum(debit) then
sum(debit)-sum(credit)
when sum(credit)-sum(debit)>sum(debit)-sum(credit) then
sum(credit)-sum(debit)
end trbalance from voudetail
where date <givendate
cal acute both balance in variable
total =opbal+trbal
and send this total in report as opening balance on top of report and add this amount asper condition in amount report amount is debit and totalbal is debit then
placeholdercolumn=totalbal+reportdebit
or credit then
placeholdercolumn=totalbal-reportdebit
sir I need this type of calculation in report
or
if you give me idea n query is best for me I calculate with over function and use report only for output
please sir give me idea urgent
thank
aamirMeilan (guest) wrote:
: I wrote a Report called by a Form and pass a parameter from the
: Form to the Report, successfully! But I imported a Graphic in
: the Report, and the Graphic could not get the parameter...(the
: parameter in the Report and Graphic should both pass from the
: Form).
: I call the Report by " Run_Product( REPORTS, :V_PRTNAME,
: SYNCHRONOUS, RUNTIME, FILESYSTEM, pl_id,NULL); " in the Form.
: and I imported the image from file for the Graphic in the
Report.
: Thanks for your help!
Meilan,
This forum is for Headstart related questions and experiences
only. Please go to metalink.oracle.com to get more information on
your problem.
Regards,
Ton
null -
Parameter passing from java applet
Hi all.
currently i'm trying to create online testing applet (like TOEFL exam) for fun.
i've create basic testing rutine, but i got stuck on showing the results.
i want to show the results on the HTML so that users can print it out easily. but i donw know how to pass parameter from Java to some other language.
I've searched for JavaScript, but it seems that it's only possible when using NetScape. Also, I searched for PHP, but it's just not possible. HTML seems that it's only possible from "HTML to Java"...
if anyone knows how i can do it, and which language i should use, please let me know.
thanx!i want to print out the questions that user have mistaken. print out the question, wrong answer, and right answer.
all the answers are created by radiobutton so i want to get the only the Strig values, which wouldn' be so difficult.
I've searched about JSObject, but could u tell me where can i install the package (or SDK)?
And do users need to install the package as well?
thanks for your time. -
How do I delete an expired Fandango pass from Passbook?
How to delete a Fandango pass from Passbook.
Hi ..
Help for deleting passes here > iOS: Using Passbook -
Hi All,
I need to modify the SQL for retrieving assets from assets tab and assets in merchandising in 10.1.2. I found the class for SQLQuery builder, but I want to change the SQL.
Could you anyone please how to solve this.
Thanks & Regards,
BalaHi All,
I need to modify the SQL for retrieving assets from assets tab and assets in merchandising in 10.1.2. I found the class for SQLQuery builder, but I want to change the SQL.
Could you anyone please how to solve this.
Thanks & Regards,
Bala -
Passing parameter to VB Script from Java file
I have a jhtml(read java) page which is trying to create a virtual directory in IIS. The servlet container run on IIS. I have a VB Script file (.vbs) which creates the virtual directory. Now the vbs file needs a parameter to create a new directory every time and the directory name should be the parameter name. I am able to run the vbs from java but the parameter passing doesn't work.
String acctname = "test";
String path = "d:/ScriptTool/CreateAccountWebIIS.vbs";
String fullpath = path+" "+ "/c:"+acctname;
System.out.println("path = "+fullpath);
Process process1;
Runtime userRuntime = Runtime.getRuntime();
try
process1 = userRuntime.exec("wscript.exe " + fullpath);
discussed options
1) convert vbs to exe
2) use batch fileIf you're creating a string that is going to be used as a file name by a Windows program on a Windows command line, then you have to use the backslash to separate directories in the path.String path = "d:\\ScriptTool\\CreateAccountWebIIS.vbs";Forward slashes are okay (actually, preferred) in Java code for use by Java classes but once you hand it over to Windows you do need to follow the Windows rules.
-
How to call a exe or bat file from java program
hi,
i actually want to know that how to call a exe or bat file from program so that i can run them parallely.Try this :
String strCmd = "myFile.bat";
try
Runtime rTime = Runtime.getRuntime();
Process process = rTime.exec(strCmd);
InputStream p_in = process.getInputStream();
OutputStream p_out = process.getOutputStream();
InputStream p_err = process.getErrorStream();
p_in.close();
p_out.close();
p_err.close();
catch(Exception e) {
throw new Exception("Unable to start, "+strCmd);
} -
How to modify the parameter csi/enable from TRUE to false
i install ce7.1 ,and i can visit the http://myip:50000/sap/admin/public/index.html ,in the page ,i just want to
change the Content Filter settings
csi/enable TRUE
modify TRUE to false ,how to change the parameters
thanksHi ,
Set the profile parameter csi/enable to the value 0 in transaction RZ11. You can also use prefixes to filter individual paths (for example, if users enter data there) or exclude individual paths from filtering (for example, is users cannot enter any data there). This value is immediately active and you should therefore use this method.
Also please check below link may help you out for your query in better way::
http://help.sap.com/saphelp_nw04s/helpdata/en/37/676642991c1053e10000000a155106/frameset.htm
Thanks..
Mohit -
Pass temporary table as parameter to a procedure from Java
Hi,
I have a PL/SQL procedure that has as input parameter a temporary table. For calling this procedure from PL/SQL there is no problem: I declare a variable having the type temporary table%ROWTYPE, I fill the table with data and then call the procedure. Now I have to call this procedure form Java and I do not know how can I declare a variable of type temporary table, fill it with data and then pass it to the procedure. I have seen and implemented passing arrays of strings or numbers to stored procedures but I have no clue how can I pass the temporary table. Anyone any clues?
Thank you,
FlorinHi Avi,
the table is defined like this:
CREATE GLOBAL TEMPORARY TABLE ticket_api (
ticket VARCHAR2(16),
party_id NUMBER,
date_from DATE,
date_to DATE )
ON COMMIT PRESERVE ROWS;
there is defined a type like this:
TYPE ticket_tabletype IS
TABLE OF ticket_api%ROWTYPE;
the procedure definition is like this:
PROCEDURE get_ticket_data (
p_tickets IN ticket_tabletype ,
x_action_plan OUT NOCOPY action_plan_tabletype );
the action_plan_tabletype is defined like this:
TYPE action_plan_tabletype IS
TABLE OF action_plan_cursor%ROWTYPE;
When calling the procedure from PL/SQL I use the following code:
DECLARE
inTickets ticket_tabletype := ticket_tabletype ();
outActionPlan action_plan_tabletype;
BEGIN
inTickets.EXTEND;
inTickets(1).ticket := 'ABCDEFG';
inTickets(1).party_id := 123456789;
inTickets(1).date_from := TO_DATE('01-JAN-05', 'DD-MON-YY');
inTickets(1).date_to := SYSDATE;
get_ticket_data(
p_tickets => inTickets,
x_action_plan => outActionPlan);
DBMS_OUTPUT.PUT_LINE('Actions: '||outActionPlan.COUNT);
END;
Thanks for your quick feedback,
Florin -
How to call stored procedure having parameter as oracle type from java???
Hello,
I have created following type & stored procedure in oracle. How can i call this stored procedure from my java class?
I want to pass 2d array to this procedure.
CREATE OR REPLACE TYPE type_survey AS OBJECT ( emp_id number,emp_name varchar(100));
CREATE OR REPLACE TYPE tbl_survey AS VARRAY(100) OF type_survey;
CREATE OR REPLACE PROCEDURE INSERTEMP (pp in tbl_survey)
IS
BEGIN
FOR I IN pp.FIRST .. pp.LAST
LOOP
INSERT INTO SURVEY (id) VALUES (pp(I).emp_id);
END LOOP;
END;
/CREATE OR REPLACE TYPE type_survey AS OBJECT ( emp_id number,emp_name varchar(100));
CREATE OR REPLACE TYPE tbl_survey AS VARRAY(100) OF type_survey;
CREATE OR REPLACE PROCEDURE APP_DATA.INSERTEMP (pp in tbl_survey,result out varchar)
IS
BEGIN
FOR I IN pp.FIRST .. pp.LAST
LOOP
INSERT INTO SURVEY (id) VALUES (pp(I).emp_id);
END LOOP;
result:='done';
END;
public static void passArray() throws SQLException
Connection conn=null;
try{
conn=getOracleConnection();//this method returns connection object
catch (Exception e)
e.printStackTrace();
String[][] val=new String[2][2];
* val[0][0]="1";*
* val[0][1]="aaa";*
* val[1][0]="2";*
* val[1][0]="bbb";*
StructDescriptor desc1=StructDescriptor.createDescriptor("TYPE_SURVEY",conn);
STRUCT p1struct1 = new STRUCT(desc1,conn,_val_); *//showing error at this line*
ArrayDescriptor arraydesc = ArrayDescriptor.createDescriptor("TBL_SURVEY",conn);
ARRAY array = new ARRAY(arraydesc,conn,*p1struct1*);
CallableStatement cstmt = conn.prepareCall("{ call INSERTEMP(?,?)}");
cstmt.setObject(1,array);
cstmt.registerOutParameter(2, OracleTypes.VARCHAR);
cstmt.execute();
String res=cstmt.getString(2);
System.out.println(res);
in the above java code, I have passed 2d array of string to STRUCT constructor and passed STRUCT object i.e. p1struct1 to ARRAY constructor. is it correct? that means @bottom line, I want to pass val array to my stored porcedure. How can i do this? above code is showing following error......
Exception in thread "main" java.sql.SQLException: Fail to convert to internal representation: [Ljava.lang.String;@146c1d4
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.oracore.OracleTypeNUMBER.toNUMBER(OracleTypeNUMBER.java:540)
at oracle.jdbc.oracore.OracleTypeNUMBER.toDatum(OracleTypeNUMBER.java:54)
at oracle.sql.StructDescriptor.toOracleArray(StructDescriptor.java:717)
at oracle.sql.StructDescriptor.toArray(StructDescriptor.java:1375)
at oracle.sql.STRUCT.<init>(STRUCT.java:159)
at com.flologic.ArrayDemo.passArray(ArrayDemo.java:29)
at com.flologic.ArrayDemo.main(ArrayDemo.java:57) -
HOW TO HIDE USERID PARAMETER, WHEN CALL REPORT FROM MENU USING FORM 10G
good morning colegas
i'm from panama
when i call a report from a oracle forms menu, its send a user, pass and bd in the url, i need to hide this parameter userid,
cuando llamo un reporte desde forms, se envia el usuario, pass y bd en el url nesesito ocultar estos parametros del url, le agradeceria si alguno tiene algun eejmplo q me de, de como ocultar estos parametros
i'm using oracle forms y report 10g
this is my msn [email protected]
slds desde panamathis document show us, only when i call a report from a forms, but not from a menu!
but to hide these parameters, i need to create a bean in a block a way and the menus do not allow me to create these objects
you done this before?
you have a example?
slds desde panama -
Parameter length limition passing to java stored procedure! help
hi:
i am working with java stored procedure to do some resource consuming work. i have to pass a long string (varch2) or bytes(log raw) which is larger than 32k which is the limitation
set by oracle.
is there a walk around?
another question:
i have to call java stored procedure from session beans ( weblogic app server) and how can i make sure the code
in session beans and that in java stored procedures to be in
the same transaction?
regards
daniel wangHi Daniel,
In answer to your first question: use a CLOB (for the long string)
and a BLOB (for the long raw). Do a search for CLOB and BLOB at the
Technet site:
http://technet.oracle.com
There are lots of resources including documentation and sample code.
In answer to your second question: first, let me say that the J2EE
forum is more suitable for that question (I haven't looked yet, but
you may have posted there as well!). Anyway, you need to set an
appropriate transaction attribute in your "ejb-jar.xml" descriptor
file for your session bean. If you want to make sure that the
session bean and java stored procedure participate in the same
transaction, I suggest using "Required", as in:
<trans-attribute>Required</trans-attribute>
Hope this helps.
Good Luck,
Avi. -
How to modify or create an xml file from a xml dataset
Hi,
I'm using spry framework with xml data sources. It works
nice.
My question :
The user can change some parameters inside my dynamic data
regions. I would like to change these data in the maching xml
files. I didn't find any sample explaining how to do this.
Thank's for your helpB2B adapter? I just want some test data. Finally the setup is going to be such that some xml is going to be posted to the B2B internal channel and then on it will translate and send to Trading Partner.
-
How to modify an XML values using XSLT and Java
Hi Friends,
I wish to modify a simple xml to another xml using XSLT, please let me know what are the things i need to know to convert the XML to another XML.
If somebody can give a sample code, it will be great...
I wish to do the following sample conversion of XML
<?xml version="1.0" encoding="ISO-8859-1" ?>
<ROOT>
<NAME>TEST1</NAME>
</ROOT>so that the results look like below....
<?xml version="1.0" encoding="ISO-8859-1" ?>
<ROOT>
<NAME>TEST2</NAME>
</ROOT>Notice TEST1 is replaced with TEST2 in the 2nd XML, I wish to get that result...please help.
Thanks and Regards,
JGThanks for your nice reply... do you have a sample code...
Maybe you are looking for
-
IPhoto shows "No Photos" when importing...
iPhoto shows "No Photos" even when I have photos to import. If I restart the computer and then plug in my camera into the USB, iPhoto will pop up and show all the photos in my camera and import, but it only seems to do so immediately after restart. I
-
Can We enter Sales Invoice and Incoming Payment VIA SDK
Dear Experts We have to develop an integration bridge with retrieve data from excel sheet and upload in SAP , i want to clear is it possible to enter sales invoices and incoming payment via SDK?. If it is possible please guide me about objects name a
-
VB Like tree in Webdynpro Java
We are using Webdynpro Tree UI Control for displaying functional location hierarchy. However the standard webdynpro Tree does not display clear lines associating children's with its parents - VB Tree has these lines which is very useful for the users
-
My Tabs and Grouped Tabs were lost following reboot and not restored via History.
I closed Firefox properly and rebooted my computer. When I restarted Firefox, instead of seeing the tabs from the previous session, a window with the message that Video DownloadHelper (add on) Update 4.9.6 had been applied, and the other tabs in the
-
upgraded to v.11 and it is just crashing, a few seconds in startup. using win xp sp3 on my work,...