Tuesday, July 1, 2008

DOM automatically interpret html entities to the characters which entities represent

After the DOM parser retrieved out the content of an element by getTextContent() . The html entities were automatically translated into the characters.

So far, I didn't find a way to disable the automatic translation. So I am using org.apache.commons.lang.StringEscapeUtils to translate the special characters back to html entities.

This solution is really not a solution.

Wednesday, May 14, 2008

Monday, March 17, 2008

JAXP vs JAXB

JAXP is based on DOM or SAX.
Just like its name, JAXB is binding specified XML objects, such as XML schema, to do XML process.
I should investigate more about them and write something down here.

Thursday, January 17, 2008

mysql table "is marked as crashed and should be repaired"

Using the following command to fix the table.
REPAIR TABLE table_name

Thursday, October 18, 2007

Bind variables in oracle

After every sql submitted into Oracle, Oracle will first check the shared pool to see if there were any same statements submitted before. If there was, Oracle will use previous statement. If there wasn't, Oracle will parse the statement and analyze out a couple of executable plans and select an optimal one for this case. This process is so-called hard parse.

How about the amount of similar SQLs? such as:
select term_id, term_name, term_description from terms where term_id='1'
select term_id, term_name, term_description from terms where term_id='2'
select term_id, term_name, term_description from terms where term_id='3'
select term_id, term_name, term_description from terms where term_id='4'

Will Oracle regard them as same statements? The answer is NO. This can be a vampire for CPU, especially for web-based applications. For instance, a hundred users are listing terms which ids are from "1" to "100" at the same time. There will be 10,000 sql submitted to oracle server. And oracel has to hard parse every statement althought they are extremely similar.

Bind variables is actually designed for this. So the upper SQL could become:
SQL> variable term_id number
SQL> exec :term_id := 10
SQL> select term_id, term_name, term_description from terms where term_id=:term_id;

For using Oracle bind variables in Java, http://www.oracle.com/technology/oramag/oracle/06-mar/o26frame.html

Thursday, October 11, 2007

Issue: libsbml crashes JDK when generating sub-model

- After searching the libsbml mailing list. It was a found bug. This bug crashes JDK when software using libsbml to add elements (such as reactions or species etc.) into a model.
- So I have to switch to libsbml 3
- However, there is a bug in JDK1.5 when using libsbml3(error message is "Can't load IA 32-bit.so on a IA 32-bit platform"). To fix this bug, it requires JDK1.5 patch 10. So I bluntly upgraded to JDK1.6

After upgraded to JDK1.6, "Can't load IA 32-bit.so on a IA 32-bit platform" gone.

After Upgraded to libsbml3. Crashing JDK problems solved.

* Honestly, libsbml3 comes on a perfect timing. Otherwise, I have to use other XML parser for generating sub-model.

Known differences between libsbml2 and 3
1. getFatal() and getWarning() deprecated;
2. getNumItems became .size(), which is silly;
3. Add new classes Trigger() and Delay(), which could be gotten by model.getTrigger and model.getDelay(). Therefore, to get math equation, I have to use Trigger.getMath() or Delay.getMath(). Previous. model.getTrigger() and model.getDelay() directly return ASTNode.
4. getNameSpaces repalced getNameSpacesList. And even worse, no class NampSpace anymore. It is less OO.