org.objectweb.cjdbc.scenario.tools
Class ScenarioUtility

java.lang.Object
  extended byorg.objectweb.cjdbc.scenario.tools.ScenarioUtility

public class ScenarioUtility
extends java.lang.Object

This class defines a ScenarioUtility

Version:
1.0
Author:
Nicolas Modrzyk

Constructor Summary
ScenarioUtility()
           
 
Method Summary
static boolean checkEquals(java.sql.ResultSet rs1, java.sql.ResultSet rs2)
          Checks if two result sets have the same content
static java.util.ArrayList convertResultSet(java.sql.ResultSet set)
          Converts the result set to an array list so can be display
static Blob createBlob(java.lang.String storeFile)
          Creates a new blob from a given file
static boolean deleteDir(java.io.File dir)
          Completely deletes a directory
static void displayResultOnScreen(java.util.ArrayList result)
          Format a result and display it on the screen
static void displayResultOnScreen(java.sql.ResultSet set)
          Format a result and display it on the screen
static void displaySingleQueryResult(java.lang.String query, java.sql.Connection con)
           
static void displaySingleQueryResult(java.lang.String query, java.sql.Connection con, boolean prepare)
           
static java.util.ArrayList getSingleQueryResult(java.lang.String query, java.sql.Connection con)
          Get the result as an arraylist of executing a sql query on a connection
static java.util.ArrayList getSingleQueryResult(java.lang.String query, java.sql.Connection con, boolean prepare)
          Get the result as an arraylist of executing a sql query on a connection
static byte[] readBinary(java.io.File file)
          ReadBinary data from the file.
static void writeBinary(byte[] data, java.io.File file)
          WriteBinary data to the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScenarioUtility

public ScenarioUtility()
Method Detail

getSingleQueryResult

public static java.util.ArrayList getSingleQueryResult(java.lang.String query,
                                                       java.sql.Connection con,
                                                       boolean prepare)
                                                throws java.lang.Exception
Get the result as an arraylist of executing a sql query on a connection

Parameters:
query - sql query
con - connection to use to execute the query
prepare - if set to true, use preparedStatement instead of statement
Returns:
ArrayList of the converted ResultSet
Throws:
java.lang.Exception - if fails

getSingleQueryResult

public static java.util.ArrayList getSingleQueryResult(java.lang.String query,
                                                       java.sql.Connection con)
                                                throws java.lang.Exception
Get the result as an arraylist of executing a sql query on a connection

Parameters:
query - sql query
con - connection to use to execute the query
Returns:
ArrayList of the converted ResultSet
Throws:
java.lang.Exception - if fails

displaySingleQueryResult

public static void displaySingleQueryResult(java.lang.String query,
                                            java.sql.Connection con)
                                     throws java.lang.Exception
Throws:
java.lang.Exception
See Also:
getSingleQueryResult(String, Connection)

displaySingleQueryResult

public static void displaySingleQueryResult(java.lang.String query,
                                            java.sql.Connection con,
                                            boolean prepare)
                                     throws java.lang.Exception
Throws:
java.lang.Exception
See Also:
getSingleQueryResult(String, Connection)

displayResultOnScreen

public static void displayResultOnScreen(java.util.ArrayList result)
Format a result and display it on the screen

Parameters:
result - a converted resultset

displayResultOnScreen

public static void displayResultOnScreen(java.sql.ResultSet set)
                                  throws java.lang.Exception
Format a result and display it on the screen

Parameters:
set - a ResultSet
Throws:
java.lang.Exception - if an error occurs

convertResultSet

public static final java.util.ArrayList convertResultSet(java.sql.ResultSet set)
                                                  throws java.lang.Exception
Converts the result set to an array list so can be display

Parameters:
set - the result set with data
Returns:
ArrayList of data
Throws:
java.lang.Exception - if result set is not valid

readBinary

public static byte[] readBinary(java.io.File file)
                         throws java.io.IOException
ReadBinary data from the file. Tested ok with writeBinary param file destination target

Parameters:
file - file to read from
Returns:
file content as an array of byte
Throws:
java.io.IOException - if read fails from target

createBlob

public static Blob createBlob(java.lang.String storeFile)
                       throws java.lang.Exception
Creates a new blob from a given file

Parameters:
storeFile - the path to the file to use
Returns:
Blob which content is that of the file
Throws:
java.lang.Exception - if fails or if cannot find file

writeBinary

public static void writeBinary(byte[] data,
                               java.io.File file)
                        throws java.io.IOException
WriteBinary data to the file. Tested ok with readBinary

Parameters:
data - to be written to the file
file - destination target
Throws:
java.io.IOException - if write fails on target

checkEquals

public static boolean checkEquals(java.sql.ResultSet rs1,
                                  java.sql.ResultSet rs2)
Checks if two result sets have the same content

Parameters:
rs1 - an open result set
rs2 - an open result set
Returns:
true if the two results sets have the same data(does not checks for metadata)

deleteDir

public static boolean deleteDir(java.io.File dir)
Completely deletes a directory

Parameters:
dir - to delete
Returns:
true if it was successfully deleted


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.