SQL Maps are the core to the iBATIS Persistence Framework. These xml documents define the mappings between sql statements and your application objects. The base elements that make up the sqlmap are: resultMap resultMap elements define how returned data from select statements should be mapped to your objects. Providing relationships between object properties and columns…
Java
How to define a SQL Like statement in iBATIS sqlMaps
When utilizing the iBATIS Framework as the persistence layer of your applications, you may get stumped as to why your LIKE statements are not being handled correctly and throws errors. When at first glance the errors have to do with other parameters in the query. The solution to this problem is to program the %…
Java Code Snippet: Converting a Float or Decimal to Currency Formatted String
Java provides multiple Text Formatting classes to enable easy conversion of integers, decimals, floats, and etc into Strings. The DecimalFormat class enables the formatting of Floats and Decimals and can be used to easily display percentages and currency amounts. Example: Converting a Float into Dollars formatted String import java.text.DecimalFormat; … float amount = 100453.23f; DecimalFormat…
How to run a Java Application from Bash Script
As one that seldom finds himself having to run Java Applications from a Unix Bash Script, I thought it would be helpful to share the appropriate commands i use to execute the code and to notify the user of success or failure. For reference the folder structure I use is: app_name – lib – config…
Nested Tiles: An Apache Tiles Quick Guide to Nesting Tiles
Apache Tiles is a Java Framework used for the templating of Web Applications. Tiles allows developers to define fragments of pages that are combined to create the whole page based on page definitions. The Tiles framework is often used in conjunction with the Apache Struts Model View Controller (MVC) framework. Below are two solutions on…
Code Snippets: Utilizing JSTL forEach tag in your Web Pages
JavaServer Pages Standard Tag Library or JSTL for short is a library that contains a set of core functionality including iterations and conditionals. The tag I find myself most often using is the forEach tag to output a collection of data in a consistent format. By use of the optional status object and the if…
Code Snippets: Java Calendar – How to get the last day of the Month
The Java Calendar class provides many helpful methods for modifying Date objects. Here you will find a short code snippet for obtaining the last day of the month. To utilize the code please don’t forget to import the java.util.Calendar class or which ever Calendar you utilize. How the snippet works is it utilizes the getActualMaximum…
Code Snippets: How to set id property using Struts HTML Tag library
For those new to Struts and in particular the Struts HTML library it might come as a surprise that there is no id property on their tags. Don’t get frustrated the tag library document clearly states that the styleId property renders its assigned value as the element id. This means that instead of id use…
Tutorial: How to send email from a Java Application – via a Server requiring Authentication
In the previous tutorial we walked through how to send email from a Java Application. This tutorial extends off that and explains how to send email from a SMTP server that requires basic User Authentication in the form of a user name and password. This is performed by use of the Authenticator object. Prerequisites This…
Tutorial: How to send email from a Java Application
Sending email from your java application is very straightforward when you utilize the JavaMail API. This library contains all the functionality necessary to connect to a SMTP Mail Server and send your email to its desired recipients. The next time you have an application performing some vital functionality instead of just logging an exception send…