org.rimudb.util
Class RimuUtils

java.lang.Object
  extended by org.rimudb.util.RimuUtils

public class RimuUtils
extends java.lang.Object

Author:
Simon Ritchie

Constructor Summary
RimuUtils()
           
 
Method Summary
static int convertCount(java.lang.Object obj)
          This method safely converts the result of a SELECT COUNT(*) to an int.
static java.lang.Object[] convertPrimitiveArray(java.lang.Object array)
          Box the elements of a primitive array into an array of Objects
static java.lang.String getQualifiedTableName(java.sql.DatabaseMetaData dbmd, java.lang.String catalog, java.lang.String schema, java.lang.String table, boolean useQuotes)
          Return a fully qualified table name.
static TableMetaData loadMetaData(java.sql.Connection con, java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.Boolean guessFormatting, java.lang.Boolean useColumnText, java.lang.Boolean useColumnHeading, boolean useQuotes)
          This method determines the TableMetaData for a given table.
static java.sql.Timestamp makeTimestamp(int year, int month, int day, int hour, int minute, int second, int millisecond)
          Create a Timestamp from a given year/month/day/hour/minute/second/millisecond
static java.lang.String parseDatabaseHost(java.lang.String jdbcURL)
          Parse the host from the database URL.
static java.lang.String parseSubProtocol(java.lang.String jdbcURL)
          Return the sub-protocol of a JDBC URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RimuUtils

public RimuUtils()
Method Detail

parseDatabaseHost

public static java.lang.String parseDatabaseHost(java.lang.String jdbcURL)
Parse the host from the database URL. Because JDBC URLs contain a sub-protocol, the Java URI class does not work to parse the host name. The Java URL class attempts to perform a connection when parsing which is not always desired.

Parameters:
jdbcURL - String
Returns:
String

parseSubProtocol

public static java.lang.String parseSubProtocol(java.lang.String jdbcURL)
Return the sub-protocol of a JDBC URL. For example if the URL is jdbc:mysql://myhost.mydomain.com then 'mysql' will be returned.

Parameters:
jdbcURL -
Returns:
The sub-protocol

convertPrimitiveArray

public static java.lang.Object[] convertPrimitiveArray(java.lang.Object array)
Box the elements of a primitive array into an array of Objects

Parameters:
array - Object
Returns:
Object[]

getQualifiedTableName

public static java.lang.String getQualifiedTableName(java.sql.DatabaseMetaData dbmd,
                                                     java.lang.String catalog,
                                                     java.lang.String schema,
                                                     java.lang.String table,
                                                     boolean useQuotes)
                                              throws java.sql.SQLException
Return a fully qualified table name. This method examines the DatabaseMetaData to determine whether catalog and schema should be included in the qualified table name. If quotes are required, the appropriate quote characters for the database will be used to support the name.

Parameters:
dbmd - DatabaseMetaData
catalog - String
schema - String
table - String
useQuotes - boolean
Returns:
The qualified table name.
Throws:
java.sql.SQLException

loadMetaData

public static TableMetaData loadMetaData(java.sql.Connection con,
                                         java.lang.String catalog,
                                         java.lang.String schema,
                                         java.lang.String table,
                                         java.lang.Boolean guessFormatting,
                                         java.lang.Boolean useColumnText,
                                         java.lang.Boolean useColumnHeading,
                                         boolean useQuotes)
This method determines the TableMetaData for a given table. It attempts to determine the primary key for the table. It will find the identity key if one exists. It includes special handling for some databases (especially the iSeries) in order to calculate better property names for columns.

Parameters:
con - Connection
catalog - String
schema - String
table - String
guessFormatting - boolean
useColumnText - boolean
useColumnHeading - boolean
useQuotes - boolean
Returns:
TableMetaData

convertCount

public static int convertCount(java.lang.Object obj)
This method safely converts the result of a SELECT COUNT(*) to an int.

Parameters:
obj - Object
Returns:
int

makeTimestamp

public static java.sql.Timestamp makeTimestamp(int year,
                                               int month,
                                               int day,
                                               int hour,
                                               int minute,
                                               int second,
                                               int millisecond)
Create a Timestamp from a given year/month/day/hour/minute/second/millisecond

Parameters:
year -
month -
day -
hour -
minute -
second -
millisecond -
Returns:
Timestamp


Copyright © 2008-2011 Simon Ritchie. All Rights Reserved.