iBATIS Debugging - iBATIS

How to debug your program?

It is simple to debug your program while working with iBATIS. For this iBATIS has in-built logging support. Following are some other logging libraries and searches to debug your program.

  • Jakarta Commons Logging (JCL).
  • Log4J
  • JDK logging

You can use any of the above listed libraries along with iBATIS.

Debugging with Log4J

To debug with log4J for logging, you need to cross-check the following points −

  • The Log4J JAR file (log4j-{version}.jar) should be in the CLASSPATH.
  • You have log4j.properties available in the CLASSPATH.

Below mentioned is the log4j.properties file. Already some of the lines are commented out, if you uncomment them for will get additional debugging information.

You can find the complete documentation for Log4J from Apaches site − Log4J Documentation.

iBATIS Debugging Example

Below mentioned Java class is a very simple example that initializes and then uses the Log4J logging library for Java applications. You can use the above-mentioned property file which lies in CLASSPATH.

Compilation and Run

Make that you have set PATH and CLASSPATH appropriately before proceeding for compilation and execution.

  • Create Employee.xml as shown above.
  • Create Employee.java as shown above and compile it.
  • Create IbatisUpdate.java as shown above and compile it.
  • Create log4j.properties as shown above.
  • Execute IbatisUpdate binary to run the program.

After executing the above program you will get the following result. A record would be updated in the EMPLOYEE table and later, the same record would be read from the EMPLOYEE table.

Debug Methods

The above example includes only info() method, however you can use any of the following methods as per your requirements −

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

iBATIS Topics