Q3: explain the important term “trigger-event”, in relation to “trigger-action”
Q: can a trigger-event invoke both a before-action and an after-action?
Q: can a trigger-action be defined with select-statements alone? Does it make sense?
Q: can a trigger-action call stored programs?
Q8: Beside before-action and after-action, what other trigger-actions are supported?
A8: for-each-row-action is NOT a third type. Both mysql and oracle let you combine BEFORE and for-each-row
Q: what if a DML where-clause matches no record? Will a before-action run? How about an after-action?
A3: an insert on a table, a delete on a table, or an update OF one or more columns ON a table. In some databases(which?), a call to a stored procedure also qualifies as a trigger event
There could be other differences, but the most glaring difference is
Arguments of Socket() refer to a REMOTE endpoint.
Arguments of ServerSocket() refer to a LOCAL endpoint ONLY and never the remote, client-side endpoint
Basically 3 options
1) a listener. [[ head first servlet ]] says this is better than the other option.
2) a specialized servlet. See P368 [[ jsp ]]
I think both put the dataSource object into an “Application/Context scope attribute”
3) spring can achieve the same. Perhaps via one of the above 2.
One j4 facade — loose coupling and fewer “dependencies”.
Without a facade, a client object may need 5 instance variables to access 5 “services” either hosted in the same or hosted in a different JVM 
– logger “service”
– authentication service
– authorization service
– status-check service
– connection-pool or dataSource
– transaction manager
– sessionFactory’s static “services”
– StudentDAOFactory, ProfessorDAOFactory….
Basic OO principle lets each subject expert author (and maintain) her object, and require all client objects to get a reference  (a dependency) to her object.
 either static field or instance field
 perhaps through JNDI lookup
Some JVM profilers like JProbe can “force” GC daemon to wake up and run. We know that A regular java method can’t “force” GC daemon thread to wake up and run. But a JVM profiler is not written in java.
jconsole can invoke GC on the target JVM. It’s on the Memory tab, and also in Mbeans -> java.lang->Memory->operations
I think JProbe uses JVM Tool Interface (aka JVM Profiler Interface) to do that? Probably. See
http://java.sun.com/j2se/1.5.0/docs/guide/jvmti/jvmti.html#ForceGarbageCollection. The profiler runs in the same process as the JVM,
sharing the address space and have access to all the jvm variables, GC, threads..
Many memory leak detectors work by counting instances for each class and detect growth over time. The assumption — instance count for any class should rise and fall, not rise and rise. IMHO, This is the #1 fundamental assumption in memory leak detectors.
In general, if by design a system is supposed to generate increasing “live” objects then it will crash sooner or later. However, if under normal load the increase is slow enough relative to the lifespan between VM restarts, then it’s tolerable but still, such a design remains worrisome and questionable for a robust server-side engine.
I feel a robust design should “retire” most of its new objects for GC.
When elements exceed 75% of the “existing-buckets” , the hashmap must grow . System doesn’t care if any bucket is shared by multiple elements
Q: What if load factor is too high like 0.99, and we *allow* the hash to become very very full?
A: somehow performance is likely to suffer
Q: what if load factor is set too low, like 0.52?
%%A: I think you get too frequent rehashing(?) and you always have 48% unused memory space(?)
Q: is a bucket similar to a chain in separate-chaining?
 current capacity
 How it grows is less important now. buzzwords: rehash, double,
 default load factor of a “new HashMap()”
due to hash collision.
echo ++$x means “increment first, then evaluate” => returns the modified value
echo $x++ means “evaluate, increment last” => returns the unmodified value
Applies to Java, PHP, Perl and any language.
Many (including experienced) programmers are fuzzy about the difference. It’s best to do
x++; if (x….) instead of if(++x …)
To quickly get a TR on any tiles application like http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html, at a glance you need to identify 4 types of “resources”
1) component-jsp files like header.jsp
2) template files
3) definitions contained in tiles-defs.xml
4) user-jsp files ie any jsp files using the trio.
So now you know tiles are not that simple — the simplest demo needs at least 4 types of files.
To better understand the need for the 4 files, use the concept of “referencing”, or more simply, “mention”.
a) A template alone can’t reference a component-jsp. Internalize the fundamental reasoning. See other posts.
b) Therefore a template can’t be a URL. A URL must reference all component-jsp directly or indirectly.
c) A URL has to be a user-jsp, referencing the defitions, which in turn references template and component-jsp files
For Tiles, there’s some valuable but less-than-comprehensible code example at http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html
Background: U have a template file, containing variables, each naming a component-jsp file. Each variable is a place-holder to be substituted by the corresponding jsp.
Q: If you don’t know tiles, how would u do the substitution in a servlet container? How do you assign a header.jsp to the first variable? If first variable names “header.jsp” right within template.jsp , then we can’t reuse template.jsp in another project. We need template.jsp to be free of hard-coding.
A: You need some kind of glue-file. Tiles implents it as a set of definitions spelt out in tiles-defs.xml
Closest starting point: smarty — also contains template, variables holding large content. Smarty uses assign() to put the content into the variables and glue the parts.
event object? Ignore for now. First focus on the 2 basic players
Subject and Observer HAS-A pointer to each other. (tight coupling@@ NO. Thanks to interfaces)
– Subject HAS-A reference to each observer  in order to send them updates.
– Observer HAS-A rcontrol linked to his subject(s) in order to subscribe/unsubscribe. Usually a field in the observer.
It seems to me that they don’t normally receive these pointers by argument-passing like
– Subject doesn’t HAS-A such pointer but receives a list of observers in notifyObserver() method. However, this way, subscription has no meaning.
– Observer doesn’t HAS-A such pointer but receives it as argument when calling subscribe().
 Static collection or a collection as a field in the subject object.
[[ Head First Design Patterns ]] is good. Helps me internalize
– data passing during notification
–Usage@@ I think most (if not every) events, listeners, subscribers, publishers … take some hints from the Observer pattern.
* swing — /Intimate/ knowledge helps you chip away at swing. Events and listeners are fundamental to swing.
* java beans
* servlet — This pattern is also relevant for servlet listeners.
* threads — Observer pattern helps inter-thread communications and data sharing
* JMS, MDB @@ Confident. No need to verify
pub/sub — the observer subscribes to news published from the Subject object
listener aka observer
registration aka subscribing
FUNCTION my_func2…. IS — CREATE? not always present
DECLARE — keyword u s u a l l y omitted when declaring cursors, exceptions ..
See http://infolab.stanford.edu/~ullman/fcdb/oracle/or-plsql.html and
— Now for anon,
DECLARE — required keyword when declaring cursors, exceptions, functions ….
* dependency and new() — factory to replace new()
See also post on eclipse’s factory refactor.
see [[ head first design patterns ]]
* delegating — Abstract-Creator object delegates instantiation to concrete subclasses, because of “knowledge” and “responsibility”
* knowledge — about a specific concrete class is usually with one developer
* responsibility — ideally each developer should be owner of a small, well-defined API. Other developers write client objects
* decouple — ideally different interacting objects should not break each other when one /invariably/ undergoes a change.
In PL/SQL, these 2 are different.
I believe “return null” is a kind of “return statement”, returning from the stored program.
I believe the “null” statement has the same meaning as “no-op” in other languages??? You need it when your if/then/else has no “action” and need a no-op filler.
“A thread is basically a call stack” is not a good description, no better than “a revolver is basically a handgun”.
Q: key phrases to describe the /salient/ features of the java thread model
A1: a call stack? Certainly the very first characteristic of a thread, but same for a light-weight process or a runing shell script. The key difference is a shared address space.
A2: a (A) call stack + (B) shared variables
If you find any system exhibiting A and B, I think it would resemble java threads.
I think many if not most of the powers and challenges of multi-threading are attributable to A or B.
– Consistency and safety hazards are due to B. Locks can help but lead to liveness hazards.
– To exploit kernel threads like the 8-core T1 processors, you need separate call stacks for each kernel thread. Similar for GUI
jvmti ^ bytecode engineering.
A) profiler — is a separate OS process. This process “attaches” to the target jvm process, often via JVMTI, perhaps by some protocol? Yes
Perhaps an IPC protocol? Yes
Example: jprobe, Jrockit runtime analyzer
$ ./jprobe/jpprofiler # starting a unix process
$ ./jra/jrcmd jrarecording time=300 filename=/tmp/jra.xml.zip # Connects to the pid, starts a JRA recording of 300s and stores the result in the specified file.
B) bytecode instrumentation — like soaking clothes before washing. You first get the standard java bytecode. You feed this bytecode into some kind of “processor” (what name?), somewhat like an obfuscator or a perl text-converter.
Echoing the Decorator pattern, it produces a “decorated” bytecode. When you execute this bytecode, memory statistics would be collected and saved somewhere, perhaps a file?
HAS-A has its attractions. IS-A has its powers too. You must choose one or the other. Or must you?
1) Well if you accept additional complexities, Decorator pattern gives you some if not all the combined benefits of composition and inheritance. In one sentence, “A decorator wraps a base object and extends that decoratee object.” It’s kind of unusual and complex. I think it’s good to remember a few examples to justify it.
2) MacroCommand is another design pattern combining both hasa+isa at the same time.
 or “implements”
See P 90 [[ mysql stored procedures ]] and http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/controlstructures.htm#i2866
In Mysql and PL/SQL, you can have
– – – – > CASE my_variable_to_test
– – – – > CASE
Second form is a “searched case”, equivalent to “IF—-ELSEIF—-ELSE”