bobby, morkos

Ranch Hand
+ Follow
since Jan 04, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by bobby, morkos

Can anyone help, the below code gets executed properly in my debug mode, however it does show the error message to the screen. It works fine for all other errors except this validator plugin. Could anyone tell me what's wrong with my code below:

validation-rule.xml:

<validator name="dateRange"
classname="ca.cn.ems.web.forms.DateRangeValidator"
method="validateTwoDate"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest,
javax.servlet.ServletContext"
depends=""
msg="error.invalid.daterange"/>

validation.xml:

<form-validation>
<formset>
<form name="equipmentForm">
<field property="beginDate" depends="required,date">
<arg key="form.beginDate" />
<var>
<var-name>datePatternStrict</var-name>
<var-value>yyyy-MM-dd</var-value>
</var>
</field>
<field property="endDate" depends="required,date,dateRange">
<arg key="form.endDate" />
<var>
<var-name>datePatternStrict</var-name>
<var-value>yyyy-MM-dd</var-value>
</var>
</field>
</form>
</formset>
</form-validation>

Java:


public static boolean validateTwoDate(java.lang.Object bean,
ValidatorAction va,
Field field,
ActionErrors errors,
HttpServletRequest request,
ServletContext application) {

if (LOGGER.isInfoEnabled()) {
LOGGER.info("enter DateRangeValidator.validateTwoDate");
}

String endDate = ValidatorUtils.getValueAsString(bean, field
.getProperty());

String beginDate = ValidatorUtils.getValueAsString(bean, "beginDate");

Date startDateRet = CommonUtil.getDate(beginDate);
Date endDateRet = CommonUtil.getDate(endDate);

if (!GenericValidator.isBlankOrNull(endDate)) {
try {
if (endDateRet.before(startDateRet)) {
errors.add(field.getKey(),
Resources.getActionError(request, va, field));

return false;
}
} catch (Exception e) {
errors.add(field.getKey(),
Resources.getActionError(request, va, field));

return false;
}

}
return true;
}


Conclusion I think that the problem seems to be the java code, could anyone tell me what I'm doing wrong :

errors.add(field.getKey(), Resources.getActionError(request, va, field));

return false;
18 years ago
my 1 st connection to intantiating the pool takes
2 secs is there a way to improve on this.

Originally posted by Mark Spritzler:
Hve you checked with your DBA. Meaning have you analyzed the tables, analyzed the query, gotten an explain plan. Checked indexes already?
That is one way of speeding up your query, if you are forced to stick witht he thin driver.
Other things that can speed up queries, but not neccessariy for your case. Do you have a connection pool with connection already to handle your query. Creating the connection is always added time.
Hope that helps some.
Mark

I will install my program on Unix, and for now I'm testing on Windows. For 1000 results returned it takes 1,904 milliseconds and I need to go at somewhere 50 milliseconds. What can I do to optimize this. I use PL/SQL and the thin driver, and jdk1.3 from sun as VM. Does anyone have any recommendations where I can increase my program speed.

Originally posted by Mark Spritzler:
If your clients will have the Oracle client on their machines then I would suggest going for the oci Driver. If they don't I suggest the thin driver.
If you have an OTN Oracle Tech Net Login you can go here.

Mark

I need to find the best Jdbc driver to connect to Oracle. I need the fastest driver out there. If you can tell me where I can download the driver and why you think it's the best performant driver (speed). Thanks.
Thanks for your help and links. You been really helpful.

Originally posted by Mark Spritzler:
OK, for some reason I feel I am still off here.
It looks like the procedure is trying to first see if the record already exists. If it does it returns the ID, if not it inserts and returns a new ID.
FOr new ID, I would use the nextVal rather than currval.
Second, I don't think you need a Cursor for this type of function. And also that way my solution of the Exception handling would work, and also give less code.
Now try this

I feel much better about that one.
Here are a couple of sites I'd suggest you add to your favorites
a great link is Ask Tom.
Ask Tom is a guy at Oracle that knows everything. You ask him a question and he'll respond,
usually within the day. I have never had him fail me yet.
For those that like a good Oracle FAQ There is no better than
Ari Kaplan's Oracle Tips.

Hope that helps
Mark

22 years ago
I have this and it compiles, however it does not return anything. Could anyone tell me why?
22 years ago
What I'm doing is it correct.
The code below what does it do? I don't know what it does exactly, could you please explain me. Thanks.
ocs.registerOutParameter(1,OracleTypes.STRUCT,"RECTYPE");
ocs.registerOutParameter(2,OracleTypes.STRUCT,"RECTYPE");
ocs.registerOutParameter(3,OracleTypes.CURSOR);

Originally posted by Michael Pearson:
Why do you want to move the data from the ResultSet to an Array?
You already have a while loop that prints the ResultSet, so it would not take much to assign the ResultSet values to an Array.


[ April 25, 2002: Message edited by: bobby, morkos ]
22 years ago
My question is how do I receive that array in Java. To start, I send 2 arrays, int and varchar2 as parameters in my pl/sql function. So, I'm only interested in the java program, the code below is what I started. Could anyone tell me if I'm doing it right. Thanks in advance for any help.
StructDescriptor desc1=StructDescriptor.createDescriptor("RECTYPE",ora._con);
STRUCT p1struct = new STRUCT(desc1, ora._con, p1obj1.toArray());
STRUCT p2struct = new STRUCT(desc1, ora._con, p1obj2.toArray());

OracleCallableStatement ocs = (OracleCallableStatement )
ora._con.prepareCall("{call " +
"pegasustypes.show_pegasus(?,?,?,?)}");

ocs.setOracleObject(1, p1struct);
ocs.setOracleObject(2, p2struct);
ocs.setString(3, ownerid);
ocs.setInt(4, num);
ocs.registerOutParameter(1,OracleTypes.STRUCT,"RECTYPE");
ocs.registerOutParameter(2,OracleTypes.STRUCT,"RECTYPE");
ocs.registerOutParameter(3,OracleTypes.CURSOR);
ocs.execute();

ora._rs=(ResultSet)ocs.getObject(1);

while (ora._rs.next()){
System.out.println(ora._rs.getString("pegasus_id").toString());
}
22 years ago
yes, I'm creatring this under system. I have a very important question to ask you. In java, I want to send to pl/sql a method that takes the following:
pl/sqlmethod(p1obj1.toArray(), p1obj2.toArray(), number, varchar2)
and in pl/sql I receive the results as an Array, that I loop in java.
How do you do the above in java? I started it and could you please take a look if I'm doing it right.


Originally posted by Beksy Kurian:
Looks like you haven't created the object type rectype correctly! Are you doing this under system??!!!
Beksy

22 years ago
I have a java program which sends to Oracle as parameter an method(Array[], Array[], String, Number) and returns the results set as an object, which I have to loop in my java program to display it. Could anyone tell me how to call this method in java and how to receive the results in an object from pl/sql. Thanks.
I have started with this, could anyone tell me if I'm doing it right and correct my program.
StructDescriptor desc1=StructDescriptor.createDescriptor("RECTYPE",ora._con);
STRUCT p1struct = new STRUCT(desc1, ora._con, p1obj1);
STRUCT p2struct = new STRUCT(desc1, ora._con, p1obj2);
OracleCallableStatement ocs = (OracleCallableStatement )
ora._con.prepareCall("{call " +
"pegasustypes.show_pegasus(?,?," +
ownerid + ", " + num + ")}");
ocs.setOracleObject(1, p1struct);
ocs.setOracleObject(2, p2struct);
ocs.registerOutParameter(1,OracleTypes.STRUCT,"RECTYPE");
ocs.registerOutParameter(2,OracleTypes.STRUCT,"RECTYPE");
ocs.registerOutParameter(3,OracleTypes.CURSOR);
ocs.execute();
p1struct = ocs.getSTRUCT(1);
p2struct = ocs.getSTRUCT(2);
Object [] p1obj = p1struct.getAttributes();
Object [] p2obj = p2struct.getAttributes();
ora._rs=(ResultSet)ocs.getObject(1);
for(int k = 0; k < infos.length; k++){
System.out.println(ora._rs.getString("pegasus_id").toString());
System.out.println("Record: " + p1obj[k] + " " + p2obj[k]);
}
22 years ago
SQL> show errors;
Errors for FUNCTION SHOW:
LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0 PL/SQL: Compilation unit analysis terminated
1/28 PLS-00905: object SYSTEM.RECTYPE is invalid

Originally posted by Muhammad Farooq:
Issue command
sql> show errors;
and then see what is the problem.
HIH,

22 years ago
SQL> CREATE OR REPLACE Function show(iorec in out rectype)
2 return number
3 IS
4 v_Table NumTab := iorec.col1;
5 v_Count BINARY_INTEGER :=1;
6 BEGIN
7 LOOP
8 IF v_Table.EXISTS(v_Count) THEN
9 DBMS_OUTPUT.PUT_LINE('v_Table(' || '); ' || v_Table(v_Count));
10 v_Count := v_Count + 1;
11 ELSE
12 EXIT;
13 END IF;
14 END LOOP;
15 END;
16 /
Warning: Function created with compilation errors.

Originally posted by Muhammad Farooq:
Try this,may be this work out. Sorry as I don't have all the data on which you are working
CREATE OR REPLACE Function show(iorec in out rectype)
return number
IS
v_Table NumTab := iorec.col1;
v_Count BINARY_INTEGER :=1;
BEGIN
LOOP
IF v_Table.EXISTS(v_Count) THEN
DBMS_OUTPUT.PUT_LINE('v_Table(' || '); ' || v_Table(v_Count));
v_Count := v_Count + 1;
ELSE
EXIT;
END IF;
END LOOP;
END;
/

HIH

22 years ago
This is my program that does not compile correctly, could anyone tell me what's wrong eith my pl/sql program. Thanks.
CREATE OR REPLACE Function show(iorec in out rectype) IS
DECLARE
v_Table NumTab := iorec.col1;
v_Count BINARY_INTEGER :=1;
BEGIN
LOOP
IF v_Table.EXISTS(v_Count) THEN
DBMS_OUTPUT.PUT_LINE('v_Table(' || '); ' || v_Table(v_Count));
v_Count := v_Count + 1;
ELSE
EXIT;
END IF;
END LOOP;
END;
END show;
/
22 years ago
Please if anyone can take a look and tell me what's wrong with my program. I would really appreciate. I have started this, but I have never worked with objects. Anyways, please reply and correct my program.
My pl/sql code is:


My java program is:

[ April 18, 2002: Message edited by: bobby, morkos ]
[ April 18, 2002: Message edited by: bobby, morkos ]
22 years ago
Your a life savier. I just want my code to work so that I can use it as a reference. Thanks for taking the time to help.

Originally posted by Beksy Kurian:
let me test the code and I will get back to you soon.
Beksy

22 years ago