Rakesh API

biz.wedoit4u.databeans
Class DatabaseHelper

java.lang.Object
  extended by biz.wedoit4u.databeans.DatabaseHelper

public final class DatabaseHelper
extends java.lang.Object

A helper class that provides convenient methods to interact with a backend database. All methods are static and hence no constructor is provided to initialise this class.

Copyright 2003, Rakesh Vidyadharan and wedoit4u.biz

Version:
$Id: DatabaseHelper.java,v 1.3 2004/05/26 11:42:32 rakesh Exp $
Author:
Rakesh Vidyadharan 10th September 2003

Field Summary
private static javax.sql.DataSource dataSource
          A reference to the DataSource to be used to fetch connections from the application server's context.
private static java.lang.String WEDOIT4U_JNDI_LOCATION
          The JNDI location for the DataSource that represents the wedoit4u database schema.
 
Constructor Summary
private DatabaseHelper()
          Default constructor.
 
Method Summary
static java.sql.Connection getConnection()
          Fetch a Connection from the dataSource obtained from the WEDOIT4U_JNDI_LOCATION in the application server context.
static int getNextSequenceValue(java.lang.String sequence)
          Return the next value of the specified sequence.
static void writeToClob(oracle.sql.CLOB clob, java.lang.String content)
          Update the specified CLOB object with the contents in the string passed in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WEDOIT4U_JNDI_LOCATION

private static final java.lang.String WEDOIT4U_JNDI_LOCATION
The JNDI location for the DataSource that represents the wedoit4u database schema.

See Also:
Constant Field Values

dataSource

private static javax.sql.DataSource dataSource
A reference to the DataSource to be used to fetch connections from the application server's context.

Constructor Detail

DatabaseHelper

private DatabaseHelper()
Default constructor. Cannot be instantiated.

Method Detail

getConnection

public static final java.sql.Connection getConnection()
                                               throws javax.naming.NamingException,
                                                      java.sql.SQLException
Fetch a Connection from the dataSource obtained from the WEDOIT4U_JNDI_LOCATION in the application server context.

Returns:
Connection - A connection from the data source.
Throws:
javax.naming.NamingException - - If errors are encountered while fetching the JNDI location from the application server context.
java.sql.SQLException - - If errors are encountered while fetching a connection from the data source.

getNextSequenceValue

public static final int getNextSequenceValue(java.lang.String sequence)
                                      throws java.sql.SQLException,
                                             javax.naming.NamingException
Return the next value of the specified sequence.

Parameters:
sequence - - The name of the sequence whose next value is to be retrieved.
Returns:
int - The next value of the sequence.
Throws:
java.sql.SQLException - - If any errors are encountered while fetching the sequence value.
javax.naming.NamingException - - If any errors are encountered while fetching a reference to the database data source.

writeToClob

public static final void writeToClob(oracle.sql.CLOB clob,
                                     java.lang.String content)
                              throws java.io.IOException,
                                     java.sql.SQLException
Update the specified CLOB object with the contents in the string passed in. This method uses the Oracle specific writing to clob fields process.

Parameters:
clob - - The clob column that is to be modified.
content - - The new content that is to be written to the CLOB field.
Throws:
java.io.IOException - - If exceptions are encountered while writing to the clob object.
java.sql.SQLException - - If exceptions are encountered while truncating the existing content in the clob field.

Rakesh API

Copyright © 2002-2005 - Rakesh Vidyadharan