Artemesia Lakener

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

Recent posts by Artemesia Lakener

Originally posted by Emanuel Kadziela:
I use Spring - it has a beautiful declarative transaction management support.



What if I use JTA to handle the transaction ? Do you think Spring can do what JTA does ?
given the following snippet

public void myMethod throws Exception {
try {
// line 1
...
} finally {
// line2
// line 3
}
}

if Exception coours at "line 2" then "line 3" will NOT be executed.

try this

finally {
try {
// line 2;
} catch (Exception e) { throw e; }
// line 3
}

if Exception occurs at "line 2", "line 3" still not executed.

try this

finally {
try {
// line 2;
} catch (Exception e) {
System.out.println("don't handle it");
}
// line 3;
}

in this case, when Exception occurs in "line 2", "line 3" is executed.


Can you explain why "line 3" is not executed in the second snippet but in the 3rd snippet ?
19 years ago
if I have the following code

case A:
*****************************
try {

// do some stuff
} catch (IOException) {
// handle error
response.sendRedirect("/errorPage.jsp");
} finally {
jdbcConnection.close();
}
********************************

case B:
try {

// do some stuff
} catch (IOException) {
// handle error
return "IOException";
} finally {
jdbcConnection.close();
}
****************************************

My question is --- Will the "jdbcConnection.close()" be executed (i.e. closing the jdbc Connection) in both Case A and B when there is IOException raised ? (One is redirecting page and one is returning out of subroutine)
19 years ago
Living in Boston area. Just accepted an offer from a company A as a senior SW 2 weeks ago. Planned to start nxt week. Now all of sudden another offer came from company B. Personally I feel the offer from company B is bit more attractive. But I have signed and returned the offer package a week ago and company A is expecting me to start soon.

Really feel bad at this moment --- If I go with company B, I feel it is not professional and I don't know if it will cause any legal problem for me ? If I go with company A, just feel I miss a good opportunity.

What should I do ?
19 years ago
ORA-00020: maximum number of processes (150) exceeded

Note: I was testing a Java web application on an application server.

thanks
19 years ago
1. the standard "security alert" windows. It shows "it can't be viewed by others, but it includes a security certificate. doy ou want to proceed ? choose "yes", "no", "view certificate". What triggers this ? how to turn it on/off ?

2. sometimes between html or JSP pages, it first pops up a small box asking if you want to "retry" or "cancel", if you click "retry" the next page shows up. what triggers this ? anyway to turn this off ?

Originally posted by Rusty Shackleford:
1. a is a reference to the object not an instance of an object. That is a very important distinction. With a private variable in a class, only an instance of that class can directly access it.



But that's how java access an "instance" -- always use a reference to do it. For example, when you do "MyClass mc = new MyClass(); mc.doThis();" isn't "mc" a reference too ? I don't know how you directly play and use an "instance" as you said ? Can you show me a concrete example that you use an "instance" directly and then use this "instance" to access its private variable ?


2. First off, you do not need to pass a reference to itself. All it needs to do is call name, because add is a member of A. But the reason it works is because it is inside the class that owns name, if that makes sense. However, it is bad programming to do something like that. Proper use of mutators/acessors is more elegant.

[ February 21, 2006: Message edited by: Rusty Shackleford ]



So you mean if it is "in the same class", then that's ok, otherwise it is not ok ? But that's not what the definition says. The definition only says "private variable can only be accessed by its instance. It doesn't say anything about "in the same class" or not. Can you provide me an example that's "not in the same class but use its instance to access private variable directly" ?

Bear with me for the questions.
19 years ago

Originally posted by Rusty Shackleford:
1. a is a reference to the object not an instance of an object. That is a very important distinction. With a private variable in a class, only an instance of that class can directly access it.

But that's how java access an "instance" -- always use a reference to do it. For example, when you do "MyClass mc = new MyClass(); mc.doThis();" isn't "mc" a reference too ? I don't know how you directly play and use an "instance" as you said ? Can you show me a concrete example that you use an "instance" directly and then use this "instance" to access its private variable ?

2. First off, you do not need to pass a reference to itself. All it needs to do is call name, because add is a member of A. But the reason it works is because it is inside the class that owns name, if that makes sense. However, it is bad programming to do something like that. Proper use of mutators/acessors is more elegant.

So you mean if it is "in the same class", then that's ok, otherwise it is not ok ? But that's not what the definition says. The definition only says "private variable can only be accessed by its instance. It doesn't say anything about "in the same class" or not. Can you provide me an example that's "not in the same class but use its instance to access private variable directly" ?

Bear with me for the questions.

[ February 21, 2006: Message edited by: Rusty Shackleford ]

19 years ago
class A {
private String name;
...

public A(String name) {...}
public A add(A a) {
return new A(name + a.name);
}
}

class Test {
void test() {
A a = new A("john");
A a1 = new A("stve");
A a2 = new A("Loi");
A a3 = a1.add(a2);
System.out.println("A.name = " + a.name); // marked line
}
}

1. Everyone knows it fails in compilation because of "a.name". But, from the book, it says -- "A private variable or method may only be used by an instance of the class that declares the var or method". So, isn't "a" an instance of class A ?? It seems it satisfies the condition, why does compiler complain ??

2. why "return new A(name + a.name)" in the class A works ? i.e why can we use "a.name" here ??
19 years ago
sometimes after I hit a submit button, before the next page appear, it pops out a small window box asking if you want to "retry" or "cancel", and if I hit "retry", it displays the next page. Just wondering what triggers that small pop up ? any idea ? I use IE browser

Originally posted by Chetan Parekh:


Put this

<% String myPrefix="http://" + request.getServerName(); %>



still same error. why ?
19 years ago
JSP
<% String myPrefix="http://<%= request.getServerName() %>"; %>
<FORM action="<%= myPrefix %>/submit" method="POST">

It complains that
********
Unable to scan the character '/' which follows '%>' at line 2

******

what's wrong ?
19 years ago
JSP
Actually I think theoretically we should be able to break any JOIN among tables into a series of chained SELECT statements like --

SELECT * from Table_1 where col_1=.. and col_2=.. and col_3 IN (SELECT col_3 from Table_2 where col1=.. and col2 IN (SELECT col2 from Table_3 where col1=.. and col3=..)

Things like that, right ?
19 years ago

Originally posted by Michael Duffy:


EXPLAIN PLAN on both and see what the difference is.

Indexes, primary keys, order of JOIN - all will affect performance.



can you help further on "order of JOIN" ? if I have join among 2 big tables and 1 small Table, what order will be best ?

select * from BigTable_1, BigTable_2, SmallTable_1
select * from SmallTable_1, BigTable_1, BigTable_2
select * from BigTable_1, SmallTable_1, BigTable_2
19 years ago