My Thesis for sharing

I graduated from University College Cork, Ireland with Msc degree in 2006. Since then, I have never touched my thesis again. It is useless to only keep it in my hard drivers. I would like to take it out and hope it can help some one who may need. The thesis is put on the [...]

How to get all keys/values out of a Hashtable.

If you like to program in Java language, it is good to know there are a number of ways to get all keys/values out of a Hashtable. Hashtable ht = new Hashtable(); ht.put(“one”,new Integer(1)); ht.put(“two”,new Integer(2)); Enumeration en = ht.elements(); while(en.hasMoreElements()){ System.out.println((Integer)en.nextElement()); } or Hashtable ht = new Hashtable(); ht.put(“one”,new Integer(1)); ht.put(“two”,new Integer(2)); Iterator it=hr.keySet().Iterator(); [...]

Iterate problem in Strtuts

When I transfer a variable of action class to jsp, I find some thing interesting: If the variable is an Array, then in jsp, I need to write both first two line(1 and 2): 1: <logic:iterate id=”dish” name=”dishes” type=”myPack.Dish”> 2: <logic:present name=”dish”> 3: <bean:write name=”dish” property=”dishName”> 4: </bean:write> 5: </logic:present> 6: </logic:iterate> then no problem. [...]

Add resource mapping into the hibernate.cfg.xml file.

When you want to associate a database table with Hibernate, you must remember to add resource mapping, something like:< resource=”myPack/Category.hbm.xml”>, into the hibernate.cfg.xml file. Otherwise, the data from this table can’t be found.

A solution to an problem of Hibernate: "Servlet action is not available"

if in the xx.hbm.xml file, you made a mistake,like: you write a wrong property name which doesn’t exist in the mapping class. say: “username” is a property in the class “User.class”,but you write it as “usename”. Then the problem happens, “Servlet action is not available” will display on your page.

Different versions of Hibernate

Hibernate has version 2 and version 3. There are some differences between them, so We must pay attention to these differencs when we are programming.

The solutions to the problem:ClassNotFoundException: org.hibernate.hql.ast.HqlToken

When I run the example provided by the Hibernate 3.1.3 package, “ant eg”, I got the error: “ClassNotFoundException: org.hibernate.hql.ast.HqlToken.The solutions have two which I tried and succeeded.1: place the antlr-2.7.6rc1.jar into the jdk.xxx/jre/lib/ext directory of jdk package.2: set the “hibernate.query.factory_class” to “org.hibernate.hql.classic.ClassicQueryTranslatorFactory” in the “hibernate.properties” file.3: Or add the following sentence into the hibernate.cfg.xml file: [...]

To run Hibernate example, We must put log4jXXX.jar into the "ext" directory of JDK

To run Hibernate example successfully, We must place log4jXXX.jar into the “jre/ext” directory of JDK (like: JDK1.5.0_06). for example, we can run the example provided by Hibernate package: “ant eg”.otherwise, it will have an error: java.lang.ExceptionInInitializerError at……….Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor …..

about getImage() method

When use the method of Applet: getImage(), add the applet to a frame, and show a instance of the frame, if run it as application, it will show errors. We can use Toolkit.getImage() to replace Applet.getImage(). Also, the method of applet: getCodeBase() only can be used in applet(because getCodebase() is the URL of the applet [...]

found sql driver for IBM J9

I have succeeded in on PDA using URL(java.net.*) to get the picture from httpserver today. I try to find some api can make IBM J9 work with MySql. It seems there is not API for J9 to support the JDBC. I check the liberary of J9, found no java.sql.* inside. Somebody say I can use [...]