Async query (Sybase + others)

Q: What do we mean by Asynchronous query or Asynchronous DB connection?

A: Best answer, based on
The Sybase API knows about 1) synchronous (ie blocking, the default), 2) deferred IO (polling) and 3) async IO (call-back) modes. In the synchronous mode database requests block(see below) until a response is available. In deferred IO mode database requests return immediately (with a return code of CS_PENDING), and you check for completion with the ct_poll() call. In async IO mode the API uses a completion callback to notify the application of pending data for async operations.

—– blocking ^ polling in Sybase and other databases, based on

Asynchronous connection to a database means that multiple commands can be passed to the database server and processed simultaneously. For example, there is no need to wait for the query to return before sending another command to the database server.

Instead of waiting for a “Finished” message to be sent back from the database server, the calling application sends a query status message to the database server at set times asking “Are you done yet?” (polling) When the database server says “Yes”, the result packets start coming back.

Client can send 2 signals to server
* a periodic status check — “my query is completed and ready for download?”
* a cancel

—– polling ^ call-back, based on

To enable fully async mode, you need to have your completion callback Perl-subroutine registered, and you need to also enable async notifications, as well as setting up a timeout for requests.

Your completion callback perl-subroutine is either invoked when ct_poll() is notified of a request completion, or by the OpenClient API directly in full async mode. ^ methods static methods are just like static methods. interface methods are more “widely” used, as they must be implemented by all Collection subtypes. Maps are NOT subtypes.

* size() is a Collection interface method. Now you know ArrayList isn’t using the word “length”, as this name wouldn’t fit Sets.
– – > “length” is used for arrays as in my_array.length == 7621
* add(Object) can’t be used for Maps
* The overloaded toArray() can’t be used for Maps

INCLUDE <jsp:include> <c:import>

The 2 common alternatives are INCLUDE and .

, defined in jstl-core, is less common.

To memorize the key difference among the 3 alternatives, #1 thing to remember is

” is in the middle ground”

reads content from arbitrary URL (vs which is restricted to the jvm)
* Insert into page
* Store in variable

sql iview4fin job

Q: benefits of relational model
q: benefits of views
q: materialized views?
q: how do u go about tuning a slow sql
q: tuning tools?
q: clustered index
q: types of indexes
q: how do u do reports?
q: outer join?
q: sybase identity column
q: what columns2index
q: what do the normalization rules mean, conceptually?

NIO q&&a

Prerequisite: blocking. See other posts

Q: Typically, how many active clients can an NIO server support?
A: thousands for a single-thread NIO server

Q: How about traditional IO?
A: typically hundreds

Q: can we have a single-thread server in traditional IO? P221
A: no. when data is unavailable on the socket, the server thread would “block” and stop doing anything at all. Since there are no other threads to do anything either, the entire server freezes up in waiting, ignoring any events or signals or inputs.

Q: basic NIO server uses a single thread or multiple threads?
A: p 233

Q: in traditional IO, what’s the threading, session, socket … allocation?
A: each client is linked to a server socket, a thread.

Q: why traditional io supports limited number of clients?
A: threads can’t multiply infinitely. (No real limit on sockets.). P227 shows 2nd reason

Q: problem of thread pool?
A: thousands of active clients would require same size (heavy!) of thread pool!

Q: in one sentence, explain a major complexity in NIO programming. P232

hibernate n:m mapping

“name=” always means a property of THIS class
“table=” is necessary only for many-to-many [1] => link table required
[1] not the other 3 types. P632 [[ java enterprise ]]
Suppose the persistent object is For a given property,
“class=” is optional if the property is declared a type (like Department) with a hbm (like Department.hbm.xml)
“class=” is required if the property is a java.util.Set => no type declared for the elements in the collection. Applicable to set-mapping.