%%weblogic cluster iview q

[b] = [[ weblogic bible ]]
12-month iview questions

Q: give some cluster-techniques for java programmers in your real projects. P 802 [b]

Q: in a cluster, how do session attributes differ from context attributes@@ p 803 [b]

Q: how do u verify session transfer without a web app@@ No answer

Q: how do u know when session transfer fails (without running a web app) @@ No answer.
A: logs?

Q: can u get email alert if a cluster node fails@@

Q: how does the “system” know a node is dead or alive? What’s the “system”, exactly? P798 [b]

Q: replication frq@@ How do u verify@@ logs@@

Q: failover of active jdbc session@@ I doubt it


Q: how do u start the cluster and verify node1 and 2 are linked up@@ log@@

Q: when u deploy an app, u can choose which nodes, but can u choose whether to deploy to the admin server of the cluster? (Hint: the admin server is for the domain, not only for the cluster)

Q: deploying a webapp. do u have to copy to node1 then copy to node2@@ In that case how does the system ensure the 2 copies are identical@@
A: u copy to admin server?

java^dotnet — real reasons of CIO to choose java

* proven track record in “my” industry
* better integration with enterprise-grade infrastructure. Large systems usually need the power of Oracle/DB2/Sybase, Solaris/AIX, Weblogic/Websphere, perhaps beyond microsoft platform

* better support by “my” approved vendors — ibm, oracle, tibco, weblogic… Credible driving vendors for dotnet boil down to just 1 — Microsoft.

* avoid lock-in by microsoft. JVM is now offered by IBM and BEA.
* competent developers in java^.NET? I think at least 50% more, given the differing maturity
* more capabilities and products including open-source. Even if a single needed capability is available in java but not .NET, this one factor alone could be overwhelming.

java exception q&&a – nontrivial

A minimum custom exception : “class e1 extends Exception {}”
Q: Where’s the constructor? where’s is the e1(String) constructor?
a: a constructor is needed for the exception obj’s “new” operation

q3: when an exception is thrown, control passes to…?

a1: wrap the exception-prone statements in a try-catch

A: constructor is the invisible e1(){super();} There’s no e1(String)
constructor in this case, since u didn’t define it.

q: is there a constructor for each exception obj?
A: i think so, including the no-arg

a4: on the heap

q1: how do u keep your method “alive” if u know an exception can be thrown
prior to a normal return?

a2: inside the exception obj and the exception type (ie the full class
name), but often there’s nothing inside the obj

q4: is exception obj created with new()? on the heap?

A3: exception handler for this particular (type of) exception

q2: there is specific information about each exception. who needs this
info? where is this info stored?

struts^spring-mvc: 1-controller@@

Struts also has an “specialized” controller per action — the LoginAction/SignupAction/DetailsAction… classes, even though they only constitute part of the controller. The singular ActionServlet is the other part of the controller.

In summary, For Each action u need 0 or 1 form, 0 or more views, a 2-part controller, 1 mapping to tie them together

As you can see, the Model thingy is elusive.

illustrating minimal DB index

–an analogy to illustrate index concept (master copy on recoll->tref): a pile of receipts sorted by shipping date

one record number on each receipt => row-id
one non-unique customer name on each page.
one unique but unsorted order number on each page

Goal: given names or order numbers, quickly get to the relevant receipts without Scan.

To build an index on the unique order number is easy — use a spreadsheet or a stack of cards to record the order-numbers vs receipt-numbers, and sort by order-number. (B*-tree is slightly diff)

To build an index on names… After sorting, cards with same names would come together. U need to consolidate them on 1 card.

sql normenclature

Clarity and brevity are the #1 and #2 goals of technical communication.

A stored function can serve as a “select ITEM”, an “order-by-ATTRIBUTE”, a “group-by-FIELD”, or part of a “where-CRITERIA” or “having-PREDICATE” — “criteria/predicate” are more precise than “condition”.

A view and a sub-select can serve as a “from TARGET”

A forkey entry/value “references” a prikey entry/value.
3 forkeys (columns) can “refererence/point-to/refer-to” the same prikey.
A table can have 2 forkeys (columns) pointing to 2 prikeys, in 2 tables.

“20 rows, each containg 4 FIELDS” —- Avoid “column” .

A column can “hold 14 ENTRIES / values ” (Avoid “values” ) but only 9 “distinct values” including the special “null value”.

The 14 entries include 2 “null ENTRIES / values” (Avoid “values” ) , so there are only 12 KNOWN-VALUES.

“Entry” has a more specific meaning. “2 null entries” sound better than “2 null values”.

Many say “These 2 values are identical.”, but It’s clearer to say “These 2 RECORDS are identical” when you select several non-key columns.

“duplicate ENTRIES / RECORDS” —- Avoid “values”

%% iview quiz #9 — pl/sql

I wrote countless PL/SQL programs over 5 years but my limited recall of details isn’t convincing to interviewers. There are big volumes devoted to pl/sql. I think some big companies rely heavily on pl/sql and would value deep pl/sql experience, including lots of important details.

Sugg: put your findings on the internet and attract exposure
Sugg: develop simple learning aids such as binary frameworks
Sugg: self-quiz. Here’s a largely unordered list of mock iview questions.

– top 5 concepts: cursor, exception, perf/volume
– Keep for 2 years.
– answers? no need

a7: 2 extremely powerful uses of functions with views
1) use a function in a view definition, as a select field
2) instead-of triggers on a view can employ a function
A34: largest pl/sql procedure in our system has a few thousand lines. Largest package has millions of lines. Not sure what they do. Perhaps billing or reporting.

q: can u use a function in a view definition?
q: what if a select-into returns 0 or more than 1 row? What’s the best practice
q: a pl/sql trigger can be defined for a ROW or a TABLE. meaning?
q: what builtin packages have you used?
A: DBMS_XSLprocessor, dbms_output, utl_file, dbms_job

q34: what’s your largest pl/sql package
q7: have you used pl/sql functions with views?
q: how did you choose between global var and param-passing@@
q: common exceptions@@
A: “when no_data_found then ..”, “when zero_divide then ..” Note that %NOTFOUND is a cursor attribute and not an exception used in “when..then”

pl/sql exception ^ java exception

— raise == re-throw that same exception you caught
Unlikely java, “raise” is a one-word statement. No need to mention the exception name.

An uncaught exception is thrown to the enclosing caller on the call stack.

–when when when == catch catch catch

–when other == catch (Exception ex)

–oracle standard exception == java standard exception
–pl/sql user-defined exception == java custom exception
error message = toString() of the custom exception

biz rules ] DB

What are Business rules? They are set by the business. These guys have written rules. Don’t ask me exactly what qualify and what don’t qualify as business rules. Business rules can be implemented in java, javascript or batch.

Many business rules are best implemented inside the DB. Reason? The concept of biz rule is popularized and heavily influenced by DB industry, vendors and practitioners. Most things that /pass as/ biz rules are defined in terms of DB records (real world objects represented by records). As a result, these biz rules can be and often are best described, saved, encoded in a DB format.

Below are just a few buzzwords, not meant to be an orthogonal, mutually exclusive list of things.

– unique constraint — eg: member id must be unique
– not-null — eg: “We can’t leave this field blank”
– RI — May not be a rule set by business, but closely related to other business rules. eg: “When this salesperson resigns, all her customers must be assigned a replacement salesperson.”
– check constraint — Can be complex. I think (??? confirmed) they should be applied at modification time.
– triggers — can implement RI, check constraints,
– – > input-validation trigger is an important, well-defined type of
– derived data — insert or update “derived data” via triggers, to let java classes select them without “deriving”. The derivation formula contain business rules.
– authorization and access control via views and stored-procs. May not qualify as business rules.
– stored proc — most flexible. Can implement the most complex rules set by business, involving multiple objects.
– – > multi-table correlated modification via stored programs
– cascade delete
– views — can contain business rules in the view’s definition query. eg: “These class of users can only read/modify this subset of data — not those protected columns or irrelevant rows. They should always see the details of each purchase — by a table join.”

An architect should learn this list of techniques. Move business rules from java classes into DB whenever possible, to reduce the complexity of java classes. A large system usually has 60-90% of the business logic implemented in application source code (like java). That’s too much to manage. It’s good to move some to javascript or DB.

[[ pl/sql for dummies ]] advocates putting most “business logic” in DB rather than java. The most complex business logic would need big guns like
* procedures
* functions
* triggers
* complex views, perhaps containing functions in their definitions and have instead-of triggers defined on them.

pl/sql exception — template

A basic template (anon or named) is —


A longer template is

DECLARE -- sometimes u don't see DECLARE
some_var NUMBER
some_var2 DATE
user_defined_exception8 EXCEPTION; -- create a name for your custom exception
statements -- a lot
EXCEPTION -- one occurence only
WHEN standard_exception1 THEN
RAISE; -- you don't have to raise.

WHEN standard_exception25 THEN
NULL -- do nothing. Just jump to END.
-- If there's an enclosing block, continue with it

WHEN standard_exception7 THEN

WHEN user_defined_exception8 THEN

WHEN OTHER THEN -- catch-all
-- no other statements between END and the last WHEN