Casting conundrum
Howdy. I am caught in a conundrum:
Why is it that you can:
MyObject[] = (MyObject[])request.getAttribute("myOb")
(provided that "myobj" was originally an array of type MyObject)
But you cannot:
MyObject[] = (MyObject[])vector.toArray();
It is precisely b/c I constntly (successfully) cast request.getAttribute() values to a narrower type that I wound up getting confused about the casting from an object array to a narrow type (e.g. when usingVector.toArray())
Can someone help clear the fog?
Much appreciated!
I appreciate all of your help, and I do indeed use the vector.toArray(MyObj[]) method when converting. I am wondering however about the other half of the question...Namely, when using the HttpServletRequest method request.setAttribute(String name, Object attr)
How is it that the request.getAttribute() method be cast to a narrower object type upon retrieval, when the vector.toArray cannot:
MyObject[] = (MyObject[])request.getAttribute("myobj")
but not
MyObject[] = (MyObject[])vector.toArray()
Sorry about the confusion...
Melissa
Similar Messages
-
Ethernet printer conundrum.
===========================
My "network" is minimal and simple:
The DSL connection comes from the street to a Siemens/SpeedStream DSL "modem"/hub supplied by the phone company (my ISP). My desktop Mac is connected by Ethernet wire to one of the five ports on said "modem"/hub.
A Netgear RangeMax Next wireless router Gigabit Edition is also connected to one of the five ports of said modem/hub.
So far so good.
I can connect to the Internet through the wire and my wife's Macbook connects to the Internet wirelessly through the Netgear.
Then, I connect a Samsung ML-2850ND monochrome laser printer that replaces my recently, finally deceased LaserWriter IIg, to another port on the DSL modem/hub. Great, I can print from my desktop machine.
But the wirelessly connected Macbook cannot print.
Then I unplug the Samsung printer from the DSL modem/hub and connect it directly to the Netgear router. Now the Macbook can print, but it cannot connect to the Internet.
Will a network SWITCH to split the printer connection between the two routers help? Or am I dreaming?
Any other suggestions will be greatly appreciated.
Message was edited by: Ramón G CastañedaI think you should arrange a completely different configuration than the currently used in your setup.
I'll tell you how I'd conect it if it were my home network (and I have set several DSL modem and wireless routers this way).
First, connect the desktop computer to a LAN port on the Netgear router using an Ethernet cable, enter the configuration page and run the Setup Wizard, as described in this Netgear k.b. article.
You will need to enter the username and password provided by your ISP. You can get them thru the DSL modem configuration page, or by calling your ISP Support desk.
Basically, when you set PPPoE on your wireless router, it is the router the one that obtains the external ip address from your ISP, instead of the modem, which is put into "Bridged mode".
Then, the router will assign an internal ip address to every device you connect to it. Also, check the router has a lease time set to "forever".
If the Netgear router Setup Wizard fails to set to PPPoE mode, then you'll need to manually enter the modem into bridging or "bridge mode" and configure the Netgear router manually to PPPoE.
The reason I suggest you to implement this setup is that, not only the network printer and the computers will get to work they way they do, but also, in the future, if you want to add any other device to your network, you'll only need to plug it into a LAN port on the Netgear router, or join the wireless signal provided by it. It's a robust configuration.
The tricky part may be to get the modem into bridge mode... -
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> -
Get values from a node and Cast it back to a table
Hi guys!
Anyway know if it is possible to get the values from a table(That was binded previously) and cast it back to a table structure so i can manupilate the fields inside...
My scenario here is to get an input and mass update tis input into the corresponding field in the table...
Any suggestions are welcome and points will be awarded generously! ")Hi Ravikiran,
In your example you update node node_list with the content of internal table tab_list..
The content of the node can be retrieved as an itab using:
tab_list = node_list->get_static_attributes_table( ).
This method only returns the values static attributes of the node. Dynamic attributes added at runtime using dynamic programming are not returned, since they are managed in a different inside of the context node.
Best regards,
Thomas
Maybe you are looking for
-
Using the bapi BAPI_INSPECTIONPLAN_CREATE
Hi , I am using the bapi BAPI_INSPECTIONPLAN_CREATE to create inspection plans. Here I am facing one issue, as a part of this creation in inspection characteristics, I am not able to handle all the control indicators. In this control indicato
-
Adobe Flash Player 11.5 tries to install over and over
OS: Windows 7 (64 Bits) Browser: IE9 (32 Bits). Adobe Flash Player Version: 11.5.502.110 Since the update to the lastest version of flash player, everytime I restart my PC and browse to any page that use flash plugin, the User Account Control windo
-
Only a genius may reply Nokia N 70
Few days back i installed d old sis files of 6600 since dan Whenever i connect my mobile with d PC It shows the error msg again & again " PC suite file missing from the mobile" Inspite of installing the latest PC suite my phone is not detected in the
-
How to interface data acquization card(DAQ) with labview
I want to take input from labview and display it on labview envioment .all the inputs are digital and change the state of switch according to the input.
-
IPad and .mac/mobileme
visiting the "mobileme" website on my iPad prompts me to set up the mail app, etc. This is unbelievably frustrating when my girlfriend (who also has a .mac account) wants to check her mail on my iPad. Actually it seems just about impossible. Options