inmuebles.util
Class FotoBlob

java.lang.Object
  extended by inmuebles.util.FotoBlob

public class FotoBlob
extends java.lang.Object

----------------------------------------------------------------------------- Used to test the functionality of how to load and unload binary data from an Oracle BLOB. This example uses an Oracle table with the following definition: CREATE TABLE test_blob ( id NUMBER(15) , image_name VARCHAR2(1000) , image BLOB , timestamp DATE ); -----------------------------------------------------------------------------

Version:
1.0
Author:
Jeffrey M. Hunter (jhunter@idevelopment.info), http://www.idevelopment.info -----------------------------------------------------------------------------

Field Summary
private  java.sql.Connection conn
           
private  java.lang.String dbPassword
           
private  java.lang.String dbUser
           
private  java.io.File inputBinaryFile
           
private  java.lang.String inputBinaryFileName
           
private  java.io.File outputBinaryFile1
           
private  java.io.File outputBinaryFile2
           
private  java.lang.String outputBinaryFileName1
           
private  java.lang.String outputBinaryFileName2
           
 
Constructor Summary
FotoBlob(java.lang.String[] args)
          Default constructor used to create this object.
 
Method Summary
static boolean checkArguments(java.lang.String[] args)
          Validate command-line arguments to this program.
 void closeOracleConnection()
          Close Oracle database connection.
 void openOracleConnection()
          Obtain a connection to the Oracle database.
 void readBLOBToFileGet()
          Method used to write the contents (data) from an Oracle BLOB column to an O/S file.
 void readBLOBToFileStream()
          Method used to write the contents (data) from an Oracle BLOB column to an O/S file.
 java.lang.String toString()
          Override the Object toString method.
static void usage()
          Method used to print program usage to the console.
 void writeBLOBPut()
          Method used to write binary data contained in a file to an Oracle BLOB column.
 void writeBLOBStream()
          Method used to write binary data contained in a file to an Oracle BLOB column.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

inputBinaryFileName

private java.lang.String inputBinaryFileName

inputBinaryFile

private java.io.File inputBinaryFile

outputBinaryFileName1

private java.lang.String outputBinaryFileName1

outputBinaryFile1

private java.io.File outputBinaryFile1

outputBinaryFileName2

private java.lang.String outputBinaryFileName2

outputBinaryFile2

private java.io.File outputBinaryFile2

dbUser

private java.lang.String dbUser

dbPassword

private java.lang.String dbPassword

conn

private java.sql.Connection conn
Constructor Detail

FotoBlob

public FotoBlob(java.lang.String[] args)
         throws java.io.IOException
Default constructor used to create this object. Responsible for setting this object's creation date, as well as incrementing the number instances of this object.

Parameters:
args - Array of string arguments passed in from the command-line.
Throws:
java.io.IOException
Method Detail

openOracleConnection

public void openOracleConnection()
                          throws java.sql.SQLException,
                                 java.lang.IllegalAccessException,
                                 java.lang.InstantiationException,
                                 java.lang.ClassNotFoundException
Obtain a connection to the Oracle database.

Throws:
java.sql.SQLException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.ClassNotFoundException

closeOracleConnection

public void closeOracleConnection()
                           throws java.sql.SQLException
Close Oracle database connection.

Throws:
java.sql.SQLException

usage

public static void usage()
Method used to print program usage to the console.


checkArguments

public static boolean checkArguments(java.lang.String[] args)
Validate command-line arguments to this program.

Parameters:
args - Array of string arguments passed in from the command-line.
Returns:
Boolean - value of true if correct arguments, false otherwise.

toString

public java.lang.String toString()
Override the Object toString method. Used to print a version of this object to the console.

Overrides:
toString in class java.lang.Object
Returns:
String - String to be returned by this object.

writeBLOBPut

public void writeBLOBPut()
                  throws java.io.IOException,
                         java.sql.SQLException
Method used to write binary data contained in a file to an Oracle BLOB column. The method used to write the data to the BLOB uses the putBytes() method. This is one of two types of methods used to write binary data to a BLOB column. The other method uses Streams.

Throws:
java.io.IOException
java.sql.SQLException

readBLOBToFileGet

public void readBLOBToFileGet()
                       throws java.io.IOException,
                              java.sql.SQLException
Method used to write the contents (data) from an Oracle BLOB column to an O/S file. This method uses one of two ways to get data from the BLOB column - namely the getBytes() method. The other way to read data from an Oracle BLOB column is to use Streams.

Throws:
java.io.IOException
java.sql.SQLException

writeBLOBStream

public void writeBLOBStream()
                     throws java.io.IOException,
                            java.sql.SQLException
Method used to write binary data contained in a file to an Oracle BLOB column. The method used to write the data to the BLOB uses Streams. This is one of two types of methods used to write binary data to a BLOB column. The other method uses the putBytes() method.

Throws:
java.io.IOException
java.sql.SQLException

readBLOBToFileStream

public void readBLOBToFileStream()
                          throws java.io.IOException,
                                 java.sql.SQLException
Method used to write the contents (data) from an Oracle BLOB column to an O/S file. This method uses one of two ways to get data from the BLOB column - namely using Streams. The other way to read data from an Oracle BLOB column is to use getBytes() method.

Throws:
java.io.IOException
java.sql.SQLException