How to shorten many catch() statements?
In the code like the following..
try {
// the code which generates many kind of exceptions
catch(FirstException x) {
// follows a lot of exceptions
catch(SecondException x) {}
catch(ThirdException x) {}I want to shorten it without crashing the explicitness. Then, how??
I'm using JTAPI. There is a exception heaven. For example,
public Connection[] connect(Terminal origterm,
Address origaddr,
java.lang.String dialedDigits)
throws ResourceUnavailableException,
PrivilegeViolationException,
InvalidPartyException,
InvalidArgumentException,
InvalidStateException,
MethodNotSupportedExceptionIt's a war against exceptions. -_-;;
Similar Messages
-
How can I execute a statement before a VO is running
JDEVADF_11.1.1.3.PS2_GENERIC_100408.2356.5660
I use ADF BC
how can I execute a statement before a VO is runningthanks for the answer
i use a logon function before I run a VO
after a certain time will be disconnected
and I have to call the function again
sorry for my English
public String logon(String username, String password){
CallableStatement st = null;
this.username = username;
this.password = password;
try {
st = getDBTransaction().createCallableStatement("begin ep_security.LogOn(?,?); end;",0);
st.setObject(1, username);
st.setObject(2, password);
st.executeUpdate();
this.getDBTransaction().commit();
} catch (SQLException e) {
System.out.println("ERROR "+e.getMessage());
this.addWarning(new JboWarning("Quote retrieved successfully"));
System.out.println("...RETURN ERROR");
return "error";
} finally {
if (st != null) {
try {
// 7. Close the statement
st.close();
} catch (SQLException e) {
e.printStackTrace();
} -
"catch is unreachable" compiler error with java try/catch statement
I'm receiving a compiler error, "catch is unreachable", with the following code. I'm calling a method, SendMail(), which can throw two possible exceptions. I thought that the catch statements executed in order, and the first one that is caught will execute? Is their a change with J2SE 1.5 compiler? I don't want to use a generic Exception, because I want to handle the specific exceptions. Any suggestions how to fix? Thanks
try {
SendMail(....);
} catch (MessagingException e1) {
logger.fine(e1.toString());
} catch (AddressException e2) {
logger.fine(e2.toString());
public String SendMail(....) throws AddressException,
MessagingException {....I found the problem:
"A catch block handles exceptions that match its exception type (parameter) and exception types that are subclasses of its exception type (parameter). Only the first catch block that handles a particular exception type will execute, so the most specific exception type should come first. You may get a catch is unreachable syntax error if your catch blocks do not follow this order."
If I switch the order of the catch exceptions the compiler error goes away.
thanks -
Control flow: catch statement
Hi there!,
Need to know where the control passes if an error is caught in a catch statement.
Suppose no alternative error handling code has been specified. Where would control go if a terminal error occured? Would it just carry on to the next statement in the general flow or would it terminate the application/applet. By terminal, i mean something like getParameter() returning null etc..
Any help that sheds light on this is appreciated greatly.
To make this clearer, how would the program know when to exit a try catch statement if it falls into a catch statement that gave a nonsensical value?You should be careful with your terms, "an error is
caught" has a very specific meaning in Java. Errors
(instances of java.lang.Error and it's subclasses)
should not be caught (that is, with a try-catch
statement) in your code because they signal more
serious problems than usual (like ClassNotFoundError,
LinkageError, VirtualMachineError, and so on), not in
switch statements or otherwise.In certain situations they should be caught.
If I create a stand alone app with a client GUI it doesn't matter to the user if a null pointer exception, because of programmer error, occurs in the database layer. But they are going to get real upset if the app just abruptly exits which is what is going to happen if the GUI layer doesn't catch all of the exceptions. And although it is possible that one of those exceptions makes it impossible to do anything at all, it is much more likely that the GUI can at least display a message to the user before exiting. And write the stack trace to a file as well.
This is true at the interface between any two layers. And some applications will be able to continue. I certainly don't want a J2EE server exiting because one of the new beans isn't working correctly. It won't stop the other beans from working. -
Catch Statement, Help!!!
I need help with a catch statement that will give an error message when Letters are put in, i need this as im only working with numebers, Heres what i have done already. When i build the code i always get
";" expected
Thanks for your Help
jMenuKmperHourMileActionPerformed(java.awt.event.ActionEvent e)
try
String Number = ToBeConverted.getText();
double amount = new Double(Number).doubleValue();
total = (amount*.621371192);
Converted.setText("= " + total);
ToBeConverted.setEditable(false);
catch(NumberFormatException nfx)
Converted.setText(Number + " is not a valid number!");
}Your try/catch statement is bad. You have too many { } brackets in there.
The format should be
try{
// code which throws Exceptions
String Number = ToBeConverted.getText();
double amount = new Double(Number).doubleValue();
total = (amount*.621371192);
Converted.setText("= " + total);
ToBeConverted.setEditable(false);
catch(NumberFormatException nfx){
// error handler
Converted.setText(Number + " is not a valid number!");
} -
How to restore visited link state to unvisited
Hi all -
I have a pseudoclass which nicely shows a gray background
after being
visited.
After clicking in ie6 browser, the links remain gray forever!
I am unable to view in the pre-visited state to show a client
sitting next
to me.
I am viewing on my local machine
There are no cookies being set
Flushing cache doesn't do it
Closing browser doesn't do it
Even rebooting the machine doesn't do it
I guess my question is, "where is my WinXP machine
remembering the visited
state?"
Anybody know this one? Many thanks
CSS follows
a.inactive
{border: 1px solid #000000;color: #000000;text-decoration:
none;padding: 4px
7px
a.inactive:visited
{border-color: #000000; text-decoration: none;background:
#CCCCCC; color:
#000
a.inactive:hover
{border-color: #000000; text-decoration: none;background:
#B30000; color:
#fff
Michael
Many thanks for the browser information and for polishing the
CSS
It is indeed appreciated.
"Michael Fesser" <[email protected]> wrote in message
news:[email protected]..
> .oO(Ken Binney)
>
>>I have a pseudoclass which nicely shows a gray
background after being
>>visited.
>>After clicking in ie6 browser, the links remain gray
forever!
>>I am unable to view in the pre-visited state to show
a client sitting next
>>to me.
>>
>>I am viewing on my local machine
>>There are no cookies being set
>>Flushing cache doesn't do it
>>Closing browser doesn't do it
>>Even rebooting the machine doesn't do it
>
> Clear the browser history.
>
>>I guess my question is, "where is my WinXP machine
remembering the visited
>>state?"
>>Anybody know this one? Many thanks
>>
>>CSS follows
>>
>>a.inactive
>>{border: 1px solid #000000;color:
#000000;text-decoration: none;padding:
>>4px
>>7px
>>}
>>a.inactive:visited
>>{border-color: #000000; text-decoration:
none;background: #CCCCCC; color:
>>#000
>>}
>>a.inactive:hover
>>{border-color: #000000; text-decoration:
none;background: #B30000; color:
>>#fff
>>}
>
> A bit shorter:
>
> a.inactive {border: 1px solid #000; color: #000;
text-decoration: none;
> padding: 4px 7px}
> a.inactive:visited {background: #CCC}
> a.inactive:hover {background: #B30000; color: #FFF}
>
> should do the same.
>
> Micha
Michael
Many thanks for the browser information and for polishing the
CSS
It is indeed appreciated.
"Michael Fesser" <[email protected]> wrote in message
news:[email protected]..
> .oO(Ken Binney)
>
>>I have a pseudoclass which nicely shows a gray
background after being
>>visited.
>>After clicking in ie6 browser, the links remain gray
forever!
>>I am unable to view in the pre-visited state to show
a client sitting next
>>to me.
>>
>>I am viewing on my local machine
>>There are no cookies being set
>>Flushing cache doesn't do it
>>Closing browser doesn't do it
>>Even rebooting the machine doesn't do it
>
> Clear the browser history.
>
>>I guess my question is, "where is my WinXP machine
remembering the visited
>>state?"
>>Anybody know this one? Many thanks
>>
>>CSS follows
>>
>>a.inactive
>>{border: 1px solid #000000;color:
#000000;text-decoration: none;padding:
>>4px
>>7px
>>}
>>a.inactive:visited
>>{border-color: #000000; text-decoration:
none;background: #CCCCCC; color:
>>#000
>>}
>>a.inactive:hover
>>{border-color: #000000; text-decoration:
none;background: #B30000; color:
>>#fff
>>}
>
> A bit shorter:
>
> a.inactive {border: 1px solid #000; color: #000;
text-decoration: none;
> padding: 4px 7px}
> a.inactive:visited {background: #CCC}
> a.inactive:hover {background: #B30000; color: #FFF}
>
> should do the same.
>
> Micha
How to tune this update statement?
Hello,
I have to solve the following task:
Update every row in table A which has an appropriate row in table B and log what you have done in a log-table.
It is possible that there are more than one fitting rows in table A for a row in table B.
My first approach is looping over the table B and doing an update of table A for every entry in table B.
This works and looks like this:
Table A:
PK number (This is the primary key of this table)
KEY number
Table B:
KEY_OLD number
KEY_NEW number
Log table:
PK number
KEY_OLD number
KEY_NEW number
declare
TYPE PK_TAB_TYPE IS TABLE OF number INDEX BY BINARY_INTEGER;
v_tab_PK PK_TAB_TYPE;
v_empty_tab_PK PK_TAB_TYPE;
begin
for v_rec in (select * from table_B) loop
v_tab_PK := v_empty_tab_PK; /* clearing the array */
update table_A
set KEY = v_rec.KEY_NEW
where (KEY = v_rec.KEY_OLD)
returning PK bulk collect into v_tab_PK;
if (v_tab_PK.count > 0) then
for i in v_tab_PK.first..v_tab_PK.last loop
insert into TMP_TAB_LOG(PK, KEY_OLD, KEY_NEW)
values (v_tab_PK(i), v_rec.KEY_OLD, v_rec.KEY_NEW);
end loop;
end if;
end loop;
end;Because the table B can have up to 500.000 entries (and the table A has even more entries) this solution will cause many update-statements.
So I am looking for a solution which has better performance.
My second approach was using an correlated update and looks like this:
declare
TYPE PK_TAB_TYPE IS TABLE OF number INDEX BY BINARY_INTEGER;
v_tab_PK PK_TAB_TYPE;
v_empty_tab_PK PK_TAB_TYPE;
v_tab_NewKey PK_TAB_TYPE;
begin
v_tab_PK := v_empty_tab_PK; /* clear the arrays */
v_tab_NewKey := v_empty_tab_PK;
update table_A a
set KEY = (select KEY_NEW from table_B where (KEY_OLD = a.KEY))
where exists (select 'x' as OK
from table_B
where (KEY_OLD = a.KEY)
returning PK, KEY bulk collect into v_tab_PK, v_tab_NewKey;
if (v_tab_PK.count > 0) then
for i in v_tab_PK.first..v_tab_PK.last loop
insert into TMP_TAB_LOG_DUB(PK, KEY_OLD, KEY_NEW)
values (v_tab_PK(i), null, v_tab_NewKey(i));
end loop;
end if;
end;Now I have only one update statement.
The only thing missing in this second approach is the old KEY before the update in the log table.
But I have no idea how to get the old value.
Is there a possibility to modify this second approach to get the old value of the KEY before the update to write it in the log-table?
And now I need your help:
What is the best way to get a performant solution for my task?
Every help appreciated.
Regards Hartmut
Below is a script you can run in another testing schema to do the update with logging..... I have created the tables (A and B) with primary key constraints defined...
create table table_a(pk number primary key
, key number);
create table table_b(key_old number primary key
, key_new number);
create table TMP_TAB_LOG_DUB(pk number primary key
, key_old number
, key_new number);
---------insert test data
insert into table_a values(1,2);
insert into table_a values(2,2);
insert into table_a values(3,2);
insert into table_a values(11,1);
insert into table_a values(12,1);
insert into table_a values(13,1);
insert into table_a values(21,4);
insert into table_a values(22,4);
insert into table_a values(23,4);
commit;
insert into table_b values(1,3);
insert into table_b values(4,2);
commit;
----- insert to log
insert into TMP_TAB_LOG_DUB(PK, KEY_OLD, KEY_NEW)
select a.pk
, a.key as key_old
, b.key_new as key_new
from table_a a
join table_b b on a.key = b.key_old;
----- update table_a
update(select a.pk
, a.key as key_old
, b.key_new as key_new
from table_a a
join table_b b on a.key = b.key_old)
set key_old = key_new;
commit;
How to optimize this select statement its a simple select....
how to optimize this select statement as the records in earlier table is abt i million
and this simplet select statement is not executing and taking lot of time
SELECT guid
stcts
INTO table gt_corcts
FROM corcts
FOR all entries in gt_mege
WHERE /sapsll/corcts~stcts = gt_mege-ctsex
and /sapsll/corcts~guid_pobj = gt_Sagmeld-guid_pobj.
regards
Arora
Hi Arora,
Using Package size is very simple and you can avoid the time out and as well as the problem because of memory. Some time if you have too many records in the internal table, then you will get a short dump called TSV_TNEW_PAGE_ALLOC_FAILED.
Below is the sample code.
DATA p_size = 50000
SELECT field1 field2 field3
INTO TABLE itab1 PACKAGE SIZE p_size
FROM dtab
WHERE <condition>
Other logic or process on the internal table itab1
FREE itab1.
ENDSELECT.
Here the only problem is you have to put the ENDSELECT.
How it works
In the first select it will select 50000 records ( or the p_size you gave). That will be in the internal table itab1.
In the second select it will clear the 50000 records already there and append next 50000 records from the database table.
So care should be taken to do all the logic or process with in select and endselect.
Some ABAP standards may not allow you to use select-endselect. But this is the best way to handle huge data without short dumps and memory related problems.
I am using this approach. My data is much more huge than yours. At an average of atleast 5 millions records per select.
Good luck and hope this help you.
Regards,
Kasthuri Rangan Srinivasan
Exception Handling after the Catch Statement
Hi every one,
How to handle the exceptions after Catch Statement.
What does a catch statement can do?
Regards,
Johny
Hi,
Check this link:
http://help.sap.com/saphelp_nw70/helpdata/en/a9/b8eef8fe9411d4b2ee0050dadfb92b/content.htm
http://help.sap.com/saphelp_nw70/helpdata/en/cf/f2bbce142c11d3b93a0000e8353423/content.htm
Regards
Adil
Jumping to a catch statement?
hi, if I have the following code:
private String getDefaultReportName(){
String reportFolder = "Data\\Report_Name";
FileInputStream FIS;
//File reportNameFile;
try {
File folder = new File(reportFolder); //check to see if the folder exists first!
if(folder.exists()){
//then do some stuff
}//end if
else{
//if this happens, I want to jump to the catch clause automatically...
}//end else
}//end try
catch (Exception e) {
return "Report";
}I found that, in my code, i have used the 'return "Report";' line often and I would like to
just jump straight to the catch statement if that is possible. I am sure it is, but I don't
know how off the top of my head. How can I jump straight to a catch clause from a try
block? thanks!
I don't know what that's supposed to be doing, or
what point you're trying to make, but it looks like
the wrong way to use/handle exceptions.A coworker at a previous job called exceptions (we were writing in Ada) "glorified GOTO" (complaining about how another coworker used it too liberally). I believe that would apply in this case.
CHECK/EXIT contains too many ABAP statements
Hi all,
I am working in BADI MIGO. I have included few INCLUDE program in it which is throwing the following error while activating it. Please let me know if any one have come across it.
<b>Jump is too great and cannot be generated... A control structure or routine with CHECK / EXIT contains too many ABAP statements....</b>
Waiting for your reply,
Thanks,
Venki
Same error for me.
I have to call a larger macro 60 times and so I can't activate the function module. If I call the macro only 50 times it works fine.
Any idea how to solve that without a complete redesign of the code (packing the macro into a new fuction module)
Thanks,
Christian
How would I create buttons states for MCs I am creating abstract MCs
I am creating a generic website that would have abstract MCs that would load jpg or TXT fields for the user interface to allow for fast updates to the site. The MCs that would make up the user interface would be empty and load things into it using XML or PHP later on. How would I create button states for the user interface MCs. I started creating a function for every MC button state but I thought there might be a more efficient way.
would creating a array help in this case?
and is using URLRequest the way to link to pages with in a movie well the flash movie that is the site it's self?
/*---------------------------- THE START OF MY ACTION SCRIPT ------------------------------*/
var waywardLogo_mc:MovieClip = new MovieClip;
var theCollection_mc:MovieClip = new MovieClip;
var newsPage_mc:MovieClip = new MovieClip;
var whatthe#$@!doyouwant!?_mc:MovieClip = new MovieClip;
/*---------------------------- onOver ------------------------------*/
waywardLogo_mc.addEventListener(MouseEvent.ROLL_OVER,onOver);
theCollection_mc.addEventListener(MouseEvent.ROLL_OVER,onOver);
newspage_mc.addEventListener(MouseEvent.ROLL_OVER,onOver);
whatthe#$@!doyouwant!?_mc.addEventListener(MouseEvent.ROLL_OVER,onOver);
/*---------------------------- onOut ------------------------------*/
waywardLogo_mc.addEventListener(MouseEvent.ROLL_OUT,onOut);
theCollection_mc.addEventListener(MouseEvent.ROLL_OUT,onOut);
newspage_mc.addEventListener(MouseEvent.ROLL_OUT,onOut);
whatthe#$@!doyouwant!?_mc.addEventListener(MouseEvent.ROLL_OUT,onOut);
/*---------------------------- onClick ------------------------------*/
waywardLogo_mc.addEventListener(MouseEvent.CLICK,onClick);
theCollection_mc.addEventListener(MouseEvent.CLICK,onClick);
newspage_mc.addEventListener(MouseEvent.CLICK,onClick);
whatthe#$@!doyouwant!?_mc.addEventListener(MouseEvent.CLICK,onClick);
function onOver(event:MouseEvent):void
event.target.alpha = .5;
function onOut(event:MouseEvent):void
event.target.alpha = 1;
function onClick(event:MouseEvent):void
event.target.URLRequest("");
/*---------------------------- onover, onOut, onClick buttonModes ------------------------------*/
waywardLogo_mc.buttonMode = true;
theCollection_mc.buttonMode = true;
newspage_mc.buttonMode = true;
whatthe#$@!doyouwant!?_mc.buttonMode = true;
click insert/new symbol, tick movieclip, assign a name, tick export for actionscript and in the class textfield enter a name (say ButtonClass) and click ok.
attached to the first frame of your new movieclip, type stop() in the actions panel. put whatever graphic you want on-stage for your button's up stage. create another keyframe, label it "over" and put whatever graphic you want for button's over state on-stage.
in a layer above those graphics, you'll probably want to add a dynamic textfield so each of your buttons can have different text. assign the textfield and instance name (say tf) and extend its timeline to the last frame of your movieclip button.
then when you want to create a button, on your timeline you can use:
var b:ButtonClass=new ButtonClass(); // these two lines need to be entered for each button
buttonhandlerF(b,someX,someY);
//-------code between dotted lines only needs to be entered once no matter how many buttons you add --------------------
function buttonhandlerF(b:ButtonClass,x:Number,y:Number){
b.addEventListener(MouseEvent.MOUSE_OVER,overF);
b.addEventListener(MouseEVent.MOUSE_OUT,outF);
b.x=x
b.y=y
addChild(b);
function overF(e:MouseEvent){
e.currentTarget.gotoAndStop("over");
function outF(e:MouseEvent){
e.currentTarget.gotoAndStop(1);
//-------code between dotted lines only needs to be entered once --------------------
// you'll also want to create a click listener and listener function
the code between the dotted lines is amenable to being added to a ButtonClass.as class file if want to expand your capabilities.
Photoshop CS6 creates too many History States withing 1 stroke
I'm on MAC OSX 10.6.8, Photoshop CS6, using a Wacom Cintiq 12".
Too often Photoshop remembers way too many History states within one pen stroke. In previous versions I don't remember this behaviour. Previously, each stroke, no matter how long, was registered as only one History state, until I raised the pen from the tablet. Now, totally sporadically without any obvious rule, Photoshop decides to remember even 100 history states within only one stroke.
Although this is sometimes useful, if you work on really long strokes, but mostly it's highly disturbing, as after using just one tool to paint only one little circle, I loose all my other, much more important History states.
Can somebody explain to me why???
Noel Carboni wrote:
Done with a mouse I get exactly one "Brush Tool" state in the history and one "Use brush" state recorded in an action.
Could it be that your tablet driver is actually delivering information to Photoshop that makes it think you're lifting the stylus and putting it down many times per stroke?
-Noel
Hmmm... could be, but I don't know how to test it, as it happens occasionally... I don't experience it in other software, but I will keep an eye on that.
How do I use SQL statements to perform calculations with form fields????
Please help!!! I don't know how to use a SQL statement within my APEX form......
My form is below. The user will enter the values in the form. Click on Submit. Then we need to run a SQL select statement with those values.
Our form looks like this:
Start_Date ____________
Per_Period ____________
Period ____________
[Submit Button]
The user will enter these 3 values in the form.
This is an example of an user providing the values:
Start_Date 03/14/08_______
Per_Period $200.00________
Period 4____________
[Submit Button]
Then they will click the Submit Button.
The SQL statement (BELOW) returns output based on the users selections:
START_DATE PER_PERIOD PERIOD
14-MAR-2008 00:00 200 Week 1 of 4
21-MAR-2008 00:00 200 Week 2 of 4
28-MAR-2008 00:00 200 Week 3 of 4
04-APR-2008 00:00 200 Week 4 of 4
Total 800
This is the full text of the SQL that makes the output above:
with criteria as (select to_date('03/14/08', 'mm/dd/rr') as start_date,
4 as periods,
'Week' as period,
200 per_period from dual),
periods as (select 'Week' period, 7 days, 0 months from dual
union all select 'BiWeek', 14, 0 from dual
union all select 'Month', 0, 1 from dual
union all select 'ByMonth', 0, 2 from dual
union all select 'Quarter', 0, 3 from dual
union all select 'Year', 0 , 12 from dual
t1 as (
select add_months(start_date,months*(level-1))+days*(level-1) start_date,
per_period,
c.period||' '||level||' of '||c.periods period
from criteria c join periods p on c.period = p.period
connect by level <= periods)
select case grouping(start_date)
when 1 then 'Total'
else to_char(start_date)
end start_date,
sum(per_period) per_period,
period
from t1
group by rollup ((start_date, period))
THANKS VERY MUCH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
You're just doing a parameterized report, where the input fields are your parameters.
Check out the Advanced Tutorial titled Parameterized Report here:
http://download.oracle.com/docs/cd/E10513_01/doc/appdev.310/e10497/rprt_query.htm#BGBEEBJA
Good luck,
Stew
How do we use if statement in labview?moreover can i use if statement inside for loop?
how do we use if statement in labview?moreover can i use if statement inside for loop?
The if statement in LabVIEW is the Case structure. You can find that on the Structures palette right next to the For Loop. If you're still on the same subject about terminating a for loop early, then what you do is enclose your functions inside the loop with a case statment and make one of the case's empty except for one or more constants that you might have to wire. Hopefully, the attached picture will explain what I mean. Also, as I mentioned in one of your other posts, I think this technique is not as good as using a while loop. The array in the attached example is the same size no matter what and you may have to handle stripping extra or invalid elements.
Attachments:
For_Loop_with_Case.jpg 21 KB
Maybe you are looking for
-
Error while updating Group Policy
Hello All, I get the below error while updating the group policy on the user machin. C:\Users\905288>gpupdate /force Updating Policy... User Policy update has completed successfully. The following warnings were encountered during user policy processi
-
How to get our own F4 help in table maintanance generator
hi all, i developed a table maint generator. in this i have 3 fields out of three there is a field called subtype. for this i ahve to create f4 help for this. foir this field i have to display two descptions calles' sub type1 and subtype2. these are
-
Mapping Issue in Triggering Email
Hi All, I am having problem in PI Mapping. Requirement: Trigger an email target structure only if ReturnCode is not equal to 0 and 1. Source Structure Target Structure Inv
-
Can anyone tell me why the following won't compile? Error : variable f might not have been initialized return f.getName(); public void createNodes(File root, DefaultMutableTreeNode node) File [] files = root.listFiles(); for(
-
JRockit1.6-JVM Crash Fatal Error:Broken use of pinObject
[ERROR] JRockit Fatal Error: Unspecified error (52) [ERROR] Broken use of pinObject [JRockit] ERROR: The JVM has crashed. Writing crash information to /home/dedp/dedp_domain/jrockit.24865.dump. ===== BEGIN DUMP =======================================