: Class SQLUtil

com.bitmechanic.sql
Class SQLUtil

java.lang.Object
  |
  +--com.bitmechanic.sql.SQLUtil

public class SQLUtil
extends java.lang.Object

A set of utility SQL methods. Not really related to the JDBC Pool, but included because you might find it useful

Version:
$Id: SQLUtil.java,v 1.6 1999/08/25 06:20:07 pixel Exp $
Author:
James Cooper

Constructor Summary
SQLUtil()
           
 
Method Summary
static java.lang.String booleanToString(boolean b)
          returns "y" if b is true.
static java.lang.String escapeString(java.lang.String str)
          Calls escapeString(str, int) with a length of 999999
static java.lang.String escapeString(java.lang.String str, int length)
          Escapes ' with '' and truncates the string to the length specified.
static java.lang.String formatHiResMysqlDate(java.util.Date date)
          Formats a date using the SimpleDateFormat "yyyy-MM-dd HH:mm:ss"
static java.lang.String formatMysqlDate(java.util.Date date)
          Formats a date using the SimpleDateFormat "yyyy-MM-dd"
static java.lang.String notNull(java.lang.String str)
          Checks if str is null, and if it is returns an empty string.
static java.util.Date parseMysqlDate(java.lang.String date_str)
           
static boolean stringToBoolean(java.lang.String str)
          returns true if str is not null and equals "y" otherwise returns true
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLUtil

public SQLUtil()
Method Detail

escapeString

public static java.lang.String escapeString(java.lang.String str)
Calls escapeString(str, int) with a length of 999999

escapeString

public static java.lang.String escapeString(java.lang.String str,
                                            int length)
Escapes ' with '' and truncates the string to the length specified.
Parameters:
str - String to escape
length - Maximum allowable length of string

notNull

public static java.lang.String notNull(java.lang.String str)
Checks if str is null, and if it is returns an empty string. Otherwise returns str itself. Useful for wrapping around calls to rs.getString() since that will return null if the field is undefined.

formatMysqlDate

public static java.lang.String formatMysqlDate(java.util.Date date)
Formats a date using the SimpleDateFormat "yyyy-MM-dd"

parseMysqlDate

public static java.util.Date parseMysqlDate(java.lang.String date_str)

formatHiResMysqlDate

public static java.lang.String formatHiResMysqlDate(java.util.Date date)
Formats a date using the SimpleDateFormat "yyyy-MM-dd HH:mm:ss"

booleanToString

public static java.lang.String booleanToString(boolean b)
returns "y" if b is true. otherwise returns "n"

stringToBoolean

public static boolean stringToBoolean(java.lang.String str)
returns true if str is not null and equals "y" otherwise returns true