Casting X to C : ASSIGN_BASE_WRONG_ALIGNMENT
Hello all,
in my utf-16 little endian system (unicode system, 4103 system code page), I have this little program which dumps at the ASSIGN statement (exception ASSIGN_BASE_WRONG_ALIGNMENT). For information, I made sure that the program has the unicode check property active (in case there would be some bug around that).
Maybe it's a kernel problem, I use Linux x86_64.
Could you check this code, and if it works for you, could you please tell your kernel + your system code page (via SNLS transaction).
DATA x1 type x length 4.
field-symbols <c> type c.
x1 = '41004100'. "AA in utf-16 little endian
assign x1(4) to <c> casting. "<--- DUMP
write <c>.
The dump says:
In the current program, an error occurred when setting the field symbol "<C>" with ASSIGN or ASSIGNING (maybe in the combination with the CASTING addition).
When converting the base entry of the field symbol "<C>" (number in base table: 13), it was found that the target type requests a memory alignment of 2.
However, the source data object has an invalid memory alignment, that is an alignment not divisible by 2.
You may be able to avoid the error by using a different offset. The following must apply: Offset = n * 2, n >= 0
I forgot to say that I checked SAP notes and none corresponds to that issue; they only explain the general problems of alignment which is not the case here (I guess) <-- Added by: Sandra Rossi on Aug 10, 2009 11:08 AM
Here I just share my "little" generic routine to cast from X (or xstring) to C (string, N... or any other character-type data). I would be happy if someone could share a simplest way to do the same (I close this thread but don't hesitate to answer this last question ). After this routine, there is a demo.
FORM cast_copy_xstring_to_string
USING
i_xsequence TYPE xsequence
i_ignore_size_error TYPE flag
CHANGING
e_string TYPE clike
e_xstring_size_error TYPE flag.
CONSTANTS con_xbuffer_size TYPE i VALUE 10000. "large buffer, max 65535, multiple of charsize
DATA l_xbuffer TYPE x LENGTH con_xbuffer_size.
FIELD-SYMBOLS <l_c> TYPE c.
DATA l_xsequence_len TYPE i.
DATA l_xsequence_type TYPE c.
DATA l_pos TYPE i.
DATA l_len TYPE i.
DATA l_temp TYPE i.
CLEAR e_string.
CLEAR e_xstring_size_error.
* make sure the buffer size is a multiple of charsize
l_temp = con_xbuffer_size MOD cl_abap_char_utilities=>charsize.
ASSERT l_temp = 0 AND con_xbuffer_size >= cl_abap_char_utilities=>charsize.
l_pos = 0.
DESCRIBE FIELD i_xsequence TYPE l_xsequence_type LENGTH l_xsequence_len IN BYTE MODE.
IF l_xsequence_type = cl_abap_typedescr=>TYPEKIND_XSTRING.
l_xsequence_len = XSTRLEN( I_xsequence ). "before 6.10, use STRLEN
ENDIF.
l_temp = l_xsequence_len MOD cl_abap_char_utilities=>charsize.
IF l_temp <> 0 AND i_ignore_size_error IS INITIAL.
e_xstring_size_error = 'X'.
ELSE.
l_len = con_xbuffer_size.
DO.
IF l_pos >= l_xsequence_len.
EXIT.
ENDIF.
l_temp = l_pos + con_xbuffer_size.
IF l_temp >= l_xsequence_len.
* last bytes
l_len = l_xsequence_len - l_pos.
l_xbuffer = i_xsequence+l_pos(l_len).
* Adjust length on the last bytes in case the input x size does not fit character size
IF i_ignore_size_error IS NOT INITIAL.
l_len = ( l_len / cl_abap_char_utilities=>charsize ) * cl_abap_char_utilities=>charsize.
ENDIF.
ELSE.
l_xbuffer = i_xsequence+l_pos(l_len).
ENDIF.
ASSIGN l_xbuffer(l_len) TO <l_c> CASTING.
CONCATENATE e_string <l_c> INTO e_string.
ADD con_xbuffer_size TO l_pos.
ENDDO.
ENDIF.
ENDFORM.
Similar Messages
-
ASSIGN_BASE_WRONG_ALIGNMENT
Hi All,
When I am executing ABAP function module RFC_READ_TABLE, I am geting following error:
ASSIGN_BASE_WRONG_ALIGNMENT
Caused by: com.sap.mw.jco.JCO$Exception: (104) RFC_ERROR_SYSTEM_FAILURE: Error in ASSIGN statement in the program SAPLSDTX .
at com.sap.mw.jco.rfc.MiddlewareRFC$Client.nativeExecute(Native Method)
at com.sap.mw.jco.rfc.MiddlewareRFC$Client.execute(MiddlewareRFC.java:1244)
at com.sap.mw.jco.JCO$Client.execute(JCO.java:3842)
at com.sap.mw.jco.JCO$Client.execute(JCO.java:3287)
This error occurs with SAP System SAP47.
But, when I try with same input values and execute this function module RFC_READ_TABLE with SAP System SAPERP04, it executes successfully.
So, Is there any version upgrade for thsi function module implemention in SAP Systems.
What can we do to avoid this error.
Below is the comlpete stack trace of error:
Error in ASSIGN statement in the program &AP.
In the current program &AP, an ASSIGN statement is supposed to
assign a field or structure to a field symbol (using either
FIELD-SYMBOLS ... STRUCTURE s ... or ASSIGN...CASTING....). When
converting the base entry of the field symbol &N1 (number in base table:
&P1), it was found that the structure s requested a memory alignment of
&P3.
The calculated offset within the source structure causes an invalid
memory alignment. (The offset must be exactly divisible by &P3).
by &P3.)
Thanks in advance.
AnkitAccording to note 382318:
Symptom
A problem occurs in function module RFC_READ_TABLE.
Reason and Prerequisites
The scope of function module RFC_READ_TABLE is very restricted. E.g., due to the fixed maximum row size only smaller tables can be accessed. There are several data types that cannot be handled, and also there are doubts regarding the Unicode compatibility of the function module.
However, all this is quite immaterial, because the function is not meant to be publicly used anyway. It was only created to be used as a sample in various training courses, and is clearly flagged as "not released for customer".
Solution
Do not use function module RFC_READ_TABLE in the first place!
Rob
Message was edited by:
Rob Burbank -
Runtime Errors ASSIGN_BASE_WRONG_ALIGNMENT
<b>Error analysis</b>
In the current program "SAPLFKH4", an error occurred when setting the
field symbol "<TEXTTAB_ACTION>" with ASSIGN or ASSIGNING (maybe in the
combination with
the CASTING addition).
When converting the base entry of the field symbol "<TEXTTAB_ACTION>" (number
in base
table: 35627), it was found that the target type requests a memory
alignment of 2.
However, the source data object has an invalid memory alignment, that is
an alignment not divisible by 2.
I have downloaded some sap notes to fix this error but all has not helped me. It seems as if this is the first error of this kind in the forum.
Please helpI have been there before but I could not find enough help.
Thanks.
Check out the short dump bellow:
<b>How to correct the error</b>
You may be able to avoid the error by using a different offset.
The following must apply: Offset = n * 2, n >= 0
You may able to find an interim solution to the problem
in the SAP note system. If you have access to the note system yourself,
please use the following search criteria:
"SAPLFKH4" "ASSIGN_BASE_WRONG_ALIGNMENT"
If you cannot solve the problem yourself, please send the
following documents to SAP:
1. A hard copy print describing the problem.
To obtain this, select the "Print" function on the current screen.
2. A suitable hardcopy prinout of the system log.
To obtain this, call the system log with Transaction SM21
and select the "Print" function to print out the relevant
part.
3. If the programs are your own programs or modified SAP programs,
supply the source code.
To do this, you can either use the "PRINT" command in the editor or
print the programs using the report RSINCL00.
4. Details regarding the conditions under which the error occurred
or which actions and input led to the error.
<b>Information on where terminated</b>
Termination occurred in the ABAP program "SAPLFKH4" - in
"VIM_TEXT_KEYTAB_ENTRIES".
The main program was "SAPLS_IMG_TOOL_5 ".
In the source code you have the termination point in line 1230
of the (Include) program "LSVIMFXL".
<b>Information on where terminated</b>
Termination occurred in the ABAP program "SAPLFKH4" - in
"VIM_TEXT_KEYTAB_ENTRIES".
The main program was "SAPLS_IMG_TOOL_5 ".
In the source code you have the termination point in line 1230
of the (Include) program "LSVIMFXL". -
these are few lines from my long STORED PROCEDURE actually i am new to oracle 11g please
declare
v_s nvarchar2(10);
p_RN nvarchar2(10);
begin
v_s := v_s || cast(p_RN as nvarchar2(10)); - ERROR IS COMING IN THIS LINE
end;
error
ORA-06550: line 5, column 39:
PLS-00103: Encountered the symbol "(" when expecting one of the following:
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
please somebody help meJust a little explanation about the error message.
ORA-06550: line 5, column 39:
PLS-00103: Encountered the symbol "(" when expecting one of the following:
Line 5 column 39 is the starting parenthesis of the "(10)". For using cast you can't add a lenght to the datatype.
If you change that, then you get a different error message:
declare
v_s nvarchar2(10);
p_RN varchar2(10);
begin
v_s := v_s || cast(p_RN as nvarchar2); -- ERROR IS COMING IN THIS LINE
end;
Fehler beim Start in Zeile 13 in Befehl:
declare
v_s nvarchar2(10);
p_RN varchar2(10);
begin
v_s := v_s || cast(p_RN as nvarchar2); -- ERROR IS COMING IN THIS LINE
end;
Fehlerbericht:
ORA-06550: line 5, column 22:
PLS-00382: expression is of wrong type
ORA-06550: line 5, column 3:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:ORA-06550: line 5, column 22:
PLS-00382: expression is of wrong type
This shows that you can't convert/cast a nvarchzar type into another nvarchar type.
It would work if you cast a number into a varchar2 type for example
declare
v_s nvarchar2(10);
p_RN number(10);
begin
v_s := v_s || cast(p_RN as nvarchar2); -- ERROR IS COMING IN THIS LINE
end;
anonymer Block abgeschlossen. -
Error in cast multiset in collections
DECLARE
TYPE emp_dept_rec IS RECORD (
v_sal emp.sal%TYPE,
v_name emp.ename%TYPE,
v_deptname dept.DEPTNAME%type
TYPE emp_dept_tab_type IS TABLE OF emp_dept_rec;
l_emp_dept_tab emp_dept_tab_type;
type emp_tab is table of emp%rowtype;
type l_emp_tab is table of emp%rowtype;
type dept_tab is table of dept%rowtype;
type l_dept_tab is table of dept%rowtype;
cursor e1 is
select * from emp;
cursor d1 is select * from dept;
begin
OPEN e1;
FETCH e1
BULK COLLECT INTO l_emp_tab;
open d1;
FETCH d1
BULK COLLECT INTO l_dept_tab;
select cast(multiset (select em.sal,em,ename ,dep.DEPTNAME
from table(l_emp_tab) em,table(l_dept_tab) dep
where em.deptno=dep.deptno)
as emp_dept_tab_type)
into l_emp_dept_tab ;
end;
it is giving error as
ORA-06550: line 43, column 25:
PL/SQL: ORA-00923: FROM keyword not found where expected
ORA-06550: line 39, column 5:
PL/SQL: SQL Statement ignoredHere is an example.
SQL> CREATE OR REPLACE TYPE emp_rec IS OBJECT (
2 v_sal NUMBER(7,2),
3 v_name VARCHAR2(35),
4 v_empno NUMBER(4),
5 v_deptno NUMBER(2)
6 )
7 ;
8 /
Type created.
SQL> CREATE OR REPLACE TYPE emp_tab IS TABLE OF emp_rec;
2 /
Type created.
SQL> CREATE OR REPLACE TYPE dept_rec IS OBJECT (
2 v_deptno NUMBER,
3 v_dname VARCHAR2(50)
4 )
5 ;
6 /
Type created.
SQL> CREATE OR REPLACE TYPE dept_tab IS TABLE OF dept_rec;
2 /
Type created.
SQL> CREATE OR REPLACE TYPE emp_dept_rec IS
2 OBJECT (
3 v_sal NUMBER,
4 v_name VARCHAR2(35),
5 v_deptname VARCHAR2(30)
6 );
7 /
Type created.
SQL> CREATE OR REPLACE TYPE emp_dept_tab_type IS TABLE OF emp_dept_rec;
2 /
Type created.
SQL> set serverout on
SQL> DECLARE
2 l_emp_dept_tab emp_dept_tab_type; --emp_dept_tab_type declared in database
3 l_emp_tab emp_tab; --emp_tab declared in database
4 l_dept_tab dept_tab; --dept_tab declared in database
5
6 CURSOR e1 IS
7 SELECT emp_rec(sal, ename, empno, deptno) FROM emp; --Note the type casting here
8
9 CURSOR d1 IS
10 SELECT dept_rec(deptno, dname) FROM dept; --Note the type casting here
11 BEGIN
12 OPEN e1;
13
14 FETCH e1 BULK COLLECT
15 INTO l_emp_tab;
16
17 OPEN d1;
18
19 FETCH d1 BULK COLLECT
20 INTO l_dept_tab;
21
22 SELECT CAST(MULTISET (SELECT em.v_sal, em.v_name, dep.v_dname
23 FROM TABLE(l_emp_tab) em, TABLE(l_dept_tab) dep
24 WHERE em.v_deptno = dep.v_deptno) AS emp_dept_tab_type)
25 INTO l_emp_dept_tab
26 FROM DUAL;
27 FOR i IN 1 .. l_emp_dept_tab.COUNT LOOP
28 dbms_output.put_line(l_emp_dept_tab(i)
29 .v_sal || '--' || l_emp_dept_tab(i)
30 .v_name || '--' || l_emp_dept_tab(i).v_deptname);
31 END LOOP;
32
33 END;
34 /
1300--MILLER--ACCOUNTING
5000--KING--ACCOUNTING
2450--CLARK--ACCOUNTING
3000--FORD--RESEARCH
1100--ADAMS--RESEARCH
3000--SCOTT--RESEARCH
2975--JONES--RESEARCH
800--SMITH--RESEARCH
950--JAMES--SALES
1500--TURNER--SALES
2850--BLAKE--SALES
1250--MARTIN--SALES
1250--WARD--SALES
1600--ALLEN--SALES
PL/SQL procedure successfully completed.It is just for educational purpose, because the thing you have achieved by so much programming can be done easily by simple join in the table itself.
user10447332 Newbie
Handle: user10447332
Status Level: Newbie
Registered: Oct 20, 2008
Total Posts: 227
Total Questions: 153 (152 unresolved) >
What a record! and most of the time you don't care to follow/revisit the thread also!. -
Hi, I test the follow Jguru tutorial code for getting atacchements
Multipart multipart = (Multipart)message.getContent();
for (int i=0, n=multipart.getCount(); i<n; i++) {
Part part = multipart.getBodyPart(i));
String disposition = part.getDisposition();
if ((disposition != null) &&
((disposition.equals(Part.ATTACHMENT) ||
(disposition.equals(Part.INLINE))) {
saveFile(part.getFileName(), part.getInputStream());
But i have a problem of cast in this line
Multipart mp = (Multipart)message.getContent();
the error of CastClass is:
java.lang.String cannot be cast to javax.mail.Multipart
why????? Please help me
ThanksMost likely you don't have a multipart message. See the msgshow.java
demo program that comes with JavaMail. -
Could not type cast in java embedding
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
org.xml.sax.InputSource in = (org.xml.sax.InputSource) getVariableData("Invoke_1_getRoutingAndFrameJumpers_OutputVariable","getRoutingAndFrameJumpersResponse");
Document doc = db.parse(in);
In the above code I am trying to type cast the variable getRoutingAndFrameJumpersResponse into org.xml.sax.InputSource so that i can parse.
I am not getting any error during compilation
but I am unable to type cast some run time error is coming in the line were I am type casting but I am not able to see the runtime error.
How can I see the runtime error in java embedding, how to type cast a variable into xml so that I can parse it.Hi Arun,
Could you try using the bpelx:rename extension in an assign activity enables a BPEL process to rename an element through use of XSD type casting.
<bpel:assign>
<bpelx:rename elementTo="QName1"? typeCastTo="QName2"?>
<bpelx:target variable="ncname" part="ncname"? query="xpath_str" />
</bpelx:rename>
</bpel:assign>
Cheers
A -
Derive found flag in SQL with where clause using TABLE(CAST function
Dear All,
Stored procedure listEmployees
==========================
CREATE OR REPLACE TYPE STRING_ARRAY AS VARRAY(8000) OF VARCHAR2(15);
empIdList STRING_ARRAY
countriesList STRING_ARRAY
SELECT EMP_ID, EMP_COUNTRY, EMP_NAME, FOUND_FLAG_
FROM EMPLOYEE WHERE
EMP_ID IN
(SELECT * FROM TABLE(CAST(empIdList AS STRING_ARRAY))
AND EMP_COUNTRY IN
(SELECT * FROM TABLE(CAST(countriesList AS STRING_ARRAY))
=================
I have a stored procedure which lists the employees using above simple query.
Here I am using table CAST function to find the list of employees in one go
instead of looping through each and every employee
Everything fine until requirements forced me to get the FOUND_FLAG as well.
Now I wanted derive the FOUND_FLAG by using rownum, rowid, decode functions
but I was not successful
Can you please suggest if there is any intelligent way to say weather the
row is found for given parameters in the where clause?
If not I may have to loop through each set of empIdList, countriesList
and find the values individually just to set a flag. In this approach I can’t use
the TABLE CAST function which is efficient I suppose.
Note that query STRING_ARRAY is an VARRAY. It is very big in size and this procedure
suppose to handle large sets of data.
Thanks In advance
Regards
Charan
Edited by: kmcharan on 03-Dec-2009 09:55
Edited by: kmcharan on 03-Dec-2009 09:55If your query returns results, you have found them... so your "FOUND" flag might be a constant,...
-
Why the cast error generates only in Widening cast?
Hi Shyam,
WELCOME TO SDN!!!
Please check this link
http://abapprogramming.blogspot.com/2007/10/oops-abap-8.html
The widening cast in this case does not cause an error because the reference airplane actually points to an instance in the subclass lcl_cargo_airplane. The dynamic type is therefore u2018REF TO lcl_cargo_airplaneu2019.
Here the widening cast produces the MOVE_CAST_ERROR runtime error that can be caught with u201CCATCH ... ENDCATCHu201D, because the airplane reference does not point to an instance in the subclass lcl_cargo_airplane, but to a u201Cgeneral airplane objectu201D. Its dynamic type is therefore u2018REF TO lcl_airplaneu2019 and does not correspond to the reference type cargo_airplane.
The widening cast logically represents the opposite of the narrowing cast. The widening cast cannot be checked statically, only at runtime. The Cast Operator u201C?=u201D (or the equivalent u201CMOVE ... ?TO u2026u201D) must be used to make this visible.
With this kind of cast, a check is carried out at runtime to ensure that the current content of the source variable corresponds to the type requirements of the target variables. In this case therefore, it checks that the dynamic type of the source reference airplane is compatible with the static type of the target reference cargo_airplane. If it is, the assignment is carried out. Otherwise the catchable runtime error u201CMOVE_CAST_ERRORu201D occurs, and the original value of the target variable remains the same.
Best regards,
raam -
Can not cast from object to int
Hi All,
I have the following bunch of code
Session session;
session = getSessionFactory().openSession();
Query query;
int MaxPageId = 0;
List list;
try{
query = session.createQuery("select max(emp.id) from EmpBean emp");
list = query.list();
MaxPageId = (int) list.get(0);
return MaxPageId;
catch(Exception e){
System.out.println(e.getMessage());
return MaxPageId;
The query executed successfully but when i get the max id in a integer variable by the following statement
MaxPageId = (int) list.get(0);
I get the following error "can not cast from object to int"
Please suggest for the same.
-ThanksCast to an Integer, not an int, and let autoboxing turn the Integer into an int.
int maxPageId;
maxPageId = (Integer) list.get(0);You can't cast objects into primitives.
Autoboxing isn't casting.
And use Java naming conventions. Local variables start with a lower-case letter. -
How to cast a column of a derived column in a view to NULL
I have a derived column in my view and this column by default is picked up as not null.
I want to cast it to null how can i do it ?
Actual column
column1 varchar(3) not null
Expected column
column1 varchar(3) null
MudassarShridar I havent defined it but the derived column has been picked up as not null which is strange
CREATE VIEW test
AS
SELECT
CASE
WHEN COMPANY_SIZE IS NULL then 'a'
ELSE 'b'
END AS
column1 ----- added derived column identifier
,[Company_Size] AS [CompanySize]
FROM xyz
Mudassar -
Oracle Arrays and getVendorConnection API and Class Cast Exception
I 've gone through various threads relating to the topic of Oracle Arrays and the getVendorConnecton API call to avoid the class Cast Exception.. i ve used all these but am still facing the problem...
I would appreciate it if some one could resolve the following queries :
I am using Weblogic 8.1 SP5 with oracle 8i
1. I read that the need to use the getVendorConnection API to make pl/sql proc calls with oracle arrays from the WL Server wont be required to avoid classCastException...
I tried to use the connection from the WL connection pool ..but it didnot work....I used the getVendorConnection API ..which also doesnot seem to work..
I got the Heurisitc Hazard exception...I used the Oracle 9i driver ie ojdbc14.jar ...after this the exception is not coming but still the code doesnt seem to work...
the snippet of the code is pasted below :
~~~~~~~~~~~~~~~~~~~~~~~code is : ~~~~~~~~~~~~~~~~~~~
/*below :
logicalCon is the Connection from the WL connection pool
JDBCcon is the JDBC connection. */
<div> try </div>
<div>{ </div>
<div>
<b>vendorConn</b> = ((WLConnection)logicalCon).getVendorConnection();
</div>
<div>
//Calling the procedure
</div>
<div>
//java.util.Map childMap1 = JDBCcon.getTypeMap();
</div>
<div>
java.util.Map childMap1 = <b>vendorConn</b>.getTypeMap();
</div>
<div>
childMap1.put("SST_ROUTE_ENTRY", Class.forName("svm.stport.ejb.StaticRouteEntry"));
</div>
<div>
//JDBCcon.setTypeMap(childMap1);
<b>vendorConn</b>.setTypeMap(childMap1);
</div>
<div>
// Create an oracle.sql.ARRAY object to hold the values
</div>
<div>
/*oracle.sql.ArrayDescriptor arrayDesc1 = oracle.sql.ArrayDescriptor.createDescriptor("SST_ROUTE_ENTRY_ARR", JDBCcon); */
</div>
<div>
oracle.sql.ArrayDescriptor arrayDesc1 =
oracle.sql.ArrayDescriptor.createDescriptor("SST_ROUTE_ENTRY_ARR", <b>vendorConn</b>); // here if i use the JDBCcon it works perfectly.... <u>^%^%^%</u>
</div>
<div>
code to fill in the sst route entry array....
.....arrayValues1 */
</div>
<div>
/* oracle.sql.ARRAY array1 = new oracle.sql.ARRAY(arrayDesc1, JDBCcon, arrayValues1); */
</div>
<div>
oracle.sql.ARRAY array1 = new oracle.sql.ARRAY(arrayDesc1, <b>vendorConn</b>, arrayValues1);
</div>
<div>
callStatement = logicalCon.prepareCall( "? = call procName(?, ?, ?)");
</div>
<div>
/* ..code to set the ?s ie array1 */
</div>
<div>
callStatement.execute();
</div>
<div>
}catch(Exceptio e){
</div>
<div>
}</div>
<div>
finally </div>
</div>{</div>
<div>System.out.println(" I ve come to finally"); </div>
<div>}</div>
<div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~code snippet ends here ~~~~~~~~~~~~~~``
</div>
I have observed that the control immediately comes to the finally block after the call to the createDescriptor line above with <u>^%^%^%</u> in the comment. If i use the JDBCCon in this line...it works perfectly fine.
Any pointers to where anything is getting wrong.
I have jst set the vendorCon to null in the end of the file and not closed it. Subsequently i have closed the logicalCon. This has been mentioned in some of the thread in this forum also.
Thanks,
-jwJatinder Wadhwa wrote:
I 've gone through various threads relating to the topic of Oracle Arrays and the getVendorConnecton API call to avoid the class Cast Exception.. i ve used all these but am still facing the problem...
I would appreciate it if some one could resolve the following queries :
I am using Weblogic 8.1 SP5 with oracle 8i
1. I read that the need to use the getVendorConnection API to make pl/sql proc calls with oracle arrays from the WL Server wont be required to avoid classCastException...
I tried to use the connection from the WL connection pool ..but it didnot work....I used the getVendorConnection API ..which also doesnot seem to work..
I got the Heurisitc Hazard exception...I used the Oracle 9i driver ie ojdbc14.jar ...after this the exception is not coming but still the code doesnt seem to work...
the snippet of the code is pasted below :
~~~~~~~~~~~~~~~~~~~~~~~code is : ~~~~~~~~~~~~~~~~~~~Hi. Show me the whole exception and stacktrace if you do:
try
vendorConn = ((WLConnection)logicalCon).getVendorConnection();
java.util.Map childMap1 = vendorConn.getTypeMap();
childMap1.put("SST_ROUTE_ENTRY" Class.forName("svm.stport.ejb.StaticRouteEntry"));
vendorConn.setTypeMap(childMap1);
oracle.sql.ArrayDescriptor arrayDesc1 =
oracle.sql.ArrayDescriptor.createDescriptor("SST_ROUTE_ENTRY_ARR",
vendorConn);
oracle.sql.ARRAY array1 = new oracle.sql.ARRAY(arrayDesc1, vendorConn, arrayValues1);
callStatement = logicalCon.prepareCall( "? = call procName(? ? ?)");
callStatement.execute();
}catch(Exception e){
e.printStackTrace();
finally
try{logicalCon.close();}catch(Exception ignore){}
System.out.println(" I ve come to finally");
/*below :
logicalCon is the Connection from the WL connection pool
JDBCcon is the JDBC connection. */
<div> try </div>
<div>{ </div>
<div>
<b>vendorConn</b> = ((WLConnection)logicalCon).getVendorConnection();
</div>
<div>
//Calling the procedure
</div>
<div>
//java.util.Map childMap1 = JDBCcon.getTypeMap();
</div>
<div>
java.util.Map childMap1 = <b>vendorConn</b>.getTypeMap();
</div>
<div>
childMap1.put("SST_ROUTE_ENTRY", Class.forName("svm.stport.ejb.StaticRouteEntry"));
</div>
<div>
//JDBCcon.setTypeMap(childMap1);
<b>vendorConn</b>.setTypeMap(childMap1);
</div>
<div>
// Create an oracle.sql.ARRAY object to hold the values
</div>
<div>
/*oracle.sql.ArrayDescriptor arrayDesc1 = oracle.sql.ArrayDescriptor.createDescriptor("SST_ROUTE_ENTRY_ARR", JDBCcon); */
</div>
<div>
oracle.sql.ArrayDescriptor arrayDesc1 =
oracle.sql.ArrayDescriptor.createDescriptor("SST_ROUTE_ENTRY_ARR", <b>vendorConn</b>); // here if i use the JDBCcon it works perfectly.... <u>^%^%^%</u>
</div>
<div>
code to fill in the sst route entry array....
.....arrayValues1 */
</div>
<div>
/* oracle.sql.ARRAY array1 = new oracle.sql.ARRAY(arrayDesc1, JDBCcon, arrayValues1); */
</div>
<div>
oracle.sql.ARRAY array1 = new oracle.sql.ARRAY(arrayDesc1, <b>vendorConn</b>, arrayValues1);
</div>
<div>
callStatement = logicalCon.prepareCall( "? = call procName(?, ?, ?)");
</div>
<div>
/* ..code to set the ?s ie array1 */
</div>
<div>
callStatement.execute();
</div>
<div>
}catch(Exceptio e){
</div>
<div>
}</div>
<div>
finally </div>
</div>{</div>
<div>System.out.println(" I ve come to finally"); </div>
<div>}</div>
<div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~code snippet ends here ~~~~~~~~~~~~~~``
</div>
I have observed that the control immediately comes to the finally block after the call to the createDescriptor line above with <u>^%^%^%</u> in the comment. If i use the JDBCCon in this line...it works perfectly fine.
Any pointers to where anything is getting wrong.
I have jst set the vendorCon to null in the end of the file and not closed it. Subsequently i have closed the logicalCon. This has been mentioned in some of the thread in this forum also.
Thanks,
-jw -
Explicit cast needed to convert java.* to to oracle.*
Hello,
I am trying to compile and run the following JSP but keep getting the "Incompatible type for = Explicit cast needed ..." error. The JSP and oracle procedure code are as follows:
<%@ page language="java" import="java.sql.*" %>
<%@ page import="oracle.jdbc.driver.*" %>
<HTML>
<HEAD>
<TITLE>
SimpleQuery JSP
</TITLE>
</HEAD>
<BODY BGCOLOR=EOFFFO>
<TABLE BORDER=1 BGCOLOR="C0C0C0">
<TH BGCOLOR="white"> <I>Node ID</I> </TH>
<%
Connection con = null;
OracleCallableStatement cstmt= null;
ResultSet rs = null;
try {
String SYSTEM_DB_DRIVER =
"oracle.jdbc.driver.OracleDriver";
String SYSTEM_DB_URL =
"jdbc:oracle:thin:@myserver.com:1521:";
String SYSTEM_DB_FILE = "CONN_STRING";
String SYSTEM_DB_USER = "UNAME";
String SYSTEM_DB_PASSWORD = "PASSWD";
Class.forName(SYSTEM_DB_DRIVER);
con = DriverManager.getConnection(SYSTEM_DB_URL +
SYSTEM_DB_FILE, SYSTEM_DB_USER, SYSTEM_DB_PASSWORD);
cstmt = con.prepareCall("call eaicl_p_requirement.open_rule_dtl(?,?)");
cstmt.registerOutParameter(1, OracleTypes.CURSOR);
<<I think I have to pass the p_product_id_in here but not sure how>>
cstmt.execute();
rs = ((OracleCallableStatement)cstmt).getCursor(1);
while(rs.next())
{%>
<TR>
<TD ALIGN=CENTER> <%= rs.getString(1) %> </TD>
<TD ALIGN=CENTER> <%= rs.getInt(2) %> </TD>
</TR>
<%}
rs.close();
cstmt.close();
con.close();
catch(Exception e)
%>
</TABLE>
</BODY>
</HTML>
The Oracle PL/SQL package.procedure it is calling is:
PROCEDURE open_rules_dtl (
prc_rules_dtl_out OUT rc_fetch_rule_dtl,
p_product_id_in IN NUMBER )
IS
vrc_rules_dtl rc_fetch_rule_dtl;
BEGIN
OPEN vrc_rules_dtl FOR
SELECT
r.rule_id,
r.rule_name,
r.rule_objective,
r.rule_description,
r.clearance_requirement,
r.rule_type
FROM
eaicl_rule r
WHERE
r.is_old = 'N' AND
r.product_id = CHR( p_product_id_in )
ORDER BY
r.rule_name
prc_rules_dtl_out := vrc_rules_dtl;
END open_rules_dtl;
I keep getting the following error on the webserver:
[05/Dec/2001:16:56:02] info ( 632): JSP: JSP1x compiler threw exception
org.apache.jasper.JasperException: Unable to compile class for JSPC:\iPlanet\Server4\https-wacc\config\..\ClassCache\_jsps\_ss_test5_jsp.java:84: Incompatible type for =. Explicit cast needed to convert java.sql.CallableStatement to oracle.jdbc.driver.OracleCallableStatement.
cstmt = con.prepareCall("call eaicl_p_requirement.open_rule_dtl(?,?)");
^
I'm not sure how to fix it. I also need to pass the p_product_id parameter to the procedure.
Hope someone can point me in the right direction. Thanks.Here's how you do an explicit cast:cstmt = (OracleCallableStatement)con.prepareCall("call eaicl_p_requirement.open_rule_dtl(?,?)");
-
Class casting, creating an image and decompiling...
Hi, I've got a couple of questions:
1)
How can I fully decompile classes, so with the implementation of the methods? Is it always possible to fully decompile a class file? When is it and when not?
2)
I aks this questions before, but I still haven't got it working, so sorry, but I ask it again :) :
I want to create my own class, for example cMyClass which extends the java.awt.Image class, which has abstract methods. How do these methods(for example getGraphics etc) have to be implemented?
3)
I can't cast a Image to cMyClass... why not?
Someone told me he did the following:
Canvas c = new Canvas()
cMyClass oImage = (cMyClass) c.createImage (100, 100);
and that this worked... I tried to do this too, and it seemed to work, but it actually didn't!!
I found out that c.createImage returns a null reference!!! That's why Java was able to cast it to my own cMyClass (not a problem to cast a null to something else), but when I created a Image (by doing a lot of unnessacary difficult stuff), and then tried to cast this Image to cMyClass it throw a ClassCastException or something like that...
How can I cast the java.awt.Image class to my class anyway?
3)
Why can't you create a image like i've done above or even like below:
Canvas c = new Canvas()
Image oImage = c.createImage (100, 100);
Why does this return a null reference?
Isn't there a better way to create an image?
4)
The getWidth and getHeight need a I thought observer...? Why is this? I just want the width and height and don't have an observer or something like that. Is there a way around this?
I tried getWidth(null) but this returns -1
Please help! :)Hi, I've got a couple of questions:
1)
How can I fully decompile classes, so with the
implementation of the methods? Is it always possible
to fully decompile a class file? When is it and when
not?You can always get a dump of the bytecode with 'javap -c'. If you don't want to figure things out yourself, try searching google for a class file decompiler, possibly a de-obfuscator.
De-compilation is completely possible if the original author wanted that, by including debugging information. Depending on the degree of such information and the amount of code obfuscation, the decompiled code may lack variable names, line numbers, field and method names, class names, and even code structure. Names and line numbers are usually not re-creatable automatically, since the information is simply lost, but you can replace them with your own strings when analyzing an unknown class file (using the correct tools). Re-creating the original code structure may work in some cases, but to me the general case looks rather close to the halt problem (i.e. not solvable).
Use a de-obfuscator, hope you've got good luck, and analyze the bytecode manually if that doesn't work.
2)
I aks this questions before, but I still haven't got
it working, so sorry, but I ask it again :) :
I want to create my own class, for example cMyClass
which extends the java.awt.Image class, which has
abstract methods. How do these methods(for example
getGraphics etc) have to be implemented?I don't really understand the problem. 'abstract' means on the language level that your subclass must provide an implementation, i.e. a method body. What that method is expected to do is explained in the javadocs for Image. But in fact you're free to do anything. You could play a sound in the getWidth() method (replace with any method name if you want). Just consider the fact that a lot of code calls getWidth in the hope of getting the width of the image, not playing a sound. So much about the language level.
On a higher level, a subclass of Image should implement a certain way to describe an image. AFAIK this means that your code must know the size of the image and know how to produce the pixels of the image. I can't tell you in general how you must do this, because it depends on your special case. This boils down to the question, why do you want to write a subclass of 'Image'? What new way of describing and image have you come up with?
3)
I can't cast a Image to cMyClass... why not?Simple, and that's certainly not an ALT. Because that specific Image is not a cMyClass. It's probably a BufferedImage or similar that was produced by AWT.
Please read the specs carefully what casting is about.
Someone told me he did the following:
Canvas c = new Canvas()
cMyClass oImage = (cMyClass) c.createImage (100,
100);
and that this worked... I tried to do this too, and it
seemed to work, but it actually didn't!!
I found out that c.createImage returns a null
reference!!! That's why Java was able to cast it to my
own cMyClass (not a problem to cast a null to
something else), but when I created a Image (by doing
a lot of unnessacary difficult stuff), and then tried
to cast this Image to cMyClass it throw a
ClassCastException or something like that...
How can I cast the java.awt.Image class to my class
anyway?You can't, and if you understood casting then you'd understand that it wouldn't make sense.
3, 4(don't know)
Maybe stupid question, but for example the BufferedImage, is this
completly written in Java?
How is the link made between the OS+hardware and the Java code? I
mean, displaying images etc. is very platform dependend not?Look for JNI (Java Native Interface). It's a way to link native (e.g. C) code with Java code. -
In SQL, when one refers to another table to display a value (e.g. a field: (select something from a_table) column_alias) the engine gives to the column an unlimited range of the datatype.
For example when I 'm getting a varchar2 value it will show up as varchar2(4000).
So, most of the time if I know the limit of the values I get, I use the following:
cast ( (select something from a_table) as varchar2(100) ) column_alias
To me, this has the benefit of not having to limit the datatype when using application development tools (Forms and Reports in my case).
The question is: Does it really matter (is it beneficial) when it comes to database memory issues to use this manner?
Thanks in advance.MichaelTsilikidis wrote:
In SQL, when one refers to another table to display a value (e.g. a field: (select something from a_table) column_alias) the engine gives to the column an unlimited range of the datatype.
For example when I 'm getting a varchar2 value it will show up as varchar2(4000).
Are you sure about that? Can you demonstrate your claim with an example? Below is an example which says otherwise.
SQL> desc emp;
Name Null? Type
EMPNO NOT NULL NUMBER
ENAME VARCHAR2(6)
JOB VARCHAR2(9)
MGR NUMBER
HIREDATE DATE
SAL NUMBER
COM NUMBER
DEPTNO NUMBER
ID NUMBER(10)
SQL> create table t
2 as
3 select (select ename from emp where mgr is null) ename
4 from dual;
Table created.
SQL> desc t;
Name Null? Type
ENAME VARCHAR2(6)
SQL>
Maybe you are looking for
-
Itunes 7.1.1 Upgrade / Exiting Program Shows ERROR message
I installed itunes 7.1.1. Afterwards when I close itunes I get an error message saying the the program encountered a problem and needs to close down. I have two options at this point debug or send an error report to Microsoft. Have done both but it s
-
The following is the sample code whcih I have used to check.<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html
-
The itunes library file cannot be saved. you do not have access privileges for this operation
Help, I just cant get rid of this error message: The itunes library file cannot be saved. you do not have enough access privileges for this operation.
-
PLEASE HELP!!!!! I THINK I GOT A VIRUS/TROJAN/WORM
Yes this is the first time this has occurred.. I will tell you what happened... Here i go Ok tonight i sent an im over aim to somebody and they said i sent a link which i didnt and i send another im to another person and they also said i sent a link
-
Hindi Support in Premiere Elements
Hi...I wanted to check if Adobe Premiere Elements supports Devnagari (Hindi) script? I am currently testing Premiere Elements 1.0 and it certainly doesn't support Hindi characters. Is the support available on any versio of Premiere Element?