BLOB access using PL/SQL or SQL

I have the following script which creates a table and populates it including an employee picture in a BLOB column.
-- * cr_lob.sql *
-- * created by Lloyd R. Weaver *
-- * February 24, 2003 *
Connect SYSTEM/MANAGER
-- * Initial cleanup *
DROP USER ORA4 CASCADE;
DROP TABLESPACE MEDIUM_VOL_DATA INCLUDING CONTENTS CASCADE CONSTRAINTS;
DROP TABLESPACE LARGE_OBJECT_INDEX INCLUDING CONTENTS CASCADE CONSTRAINTS;
DROP TABLESPACE LARGE_OBJECT_DATA INCLUDING CONTENTS CASCADE CONSTRAINTS;
DROP DIRECTORY PHOTOS;
HOST ERASE C:\ORACLE\ORADATA\ORCL\MED_VOL_DATA_F1.DBF
HOST ERASE C:\ORACLE\ORADATA\ORCL\LRG_OBJ_INDX_F1.DBF
HOST ERASE C:\ORACLE\ORADATA\ORCL\LRG_OBJ_DATA_F1.DBF
-- * Create user account for demo *
CREATE USER ORA4 IDENTIFIED BY ORA4
DEFAULT TABLESPACE USERS
QUOTA UNLIMITED ON USERS
QUOTA 0 ON SYSTEM;
GRANT DBA TO ORA4;
CONNECT ORA4/ORA4
-- * Step 1: Create Tablespaces for LOB scenario *
CREATE TABLESPACE MEDIUM_VOL_DATA
DATAFILE 'C:\ORACLE\ORADATA\ORCL\MED_VOL_DATA_F1.DBF' SIZE 2M
AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED
DEFAULT STORAGE (INITIAL 10K NEXT 10K PCTINCREASE 0 MAXEXTENTS 100)
EXTENT MANAGEMENT DICTIONARY;
CREATE TABLESPACE LARGE_OBJECT_INDEX
DATAFILE 'C:\ORACLE\ORADATA\ORCL\LRG_OBJ_INDX_F1.DBF' SIZE 2M
AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED
DEFAULT STORAGE (INITIAL 10K NEXT 10K PCTINCREASE 0 MAXEXTENTS 100)
EXTENT MANAGEMENT DICTIONARY;
CREATE TABLESPACE LARGE_OBJECT_DATA
DATAFILE 'C:\ORACLE\ORADATA\ORCL\LRG_OBJ_DATA_F1.DBF' SIZE 20M
AUTOEXTEND ON NEXT 5M MAXSIZE UNLIMITED
DEFAULT STORAGE (INITIAL 1M NEXT 1M PCTINCREASE 0 MAXEXTENTS 100)
EXTENT MANAGEMENT DICTIONARY;
-- * Step 2: Create a table with BLOB column and add primary key constraint *
CREATE TABLE LTI_INSTRUCTOR
(INST_ID NUMBER(4)
,INST_LNAME VARCHAR2(25)
,INST_FNAME VARCHAR2(12)
,INST_PHOTO BLOB DEFAULT EMPTY_BLOB())
LOB (INST_PHOTO) STORE AS INST_PHOTO_DATA_SEG
(TABLESPACE LARGE_OBJECT_DATA STORAGE (INITIAL 1M NEXT 1M PCTINCREASE 0)
DISABLE STORAGE IN ROW
CHUNK 10 NOCACHE NOLOGGING
PCTVERSION 10
INDEX INST_PHOTO_INDEX_SEG
(TABLESPACE LARGE_OBJECT_INDEX STORAGE (INITIAL 100K NEXT 100K PCTINCREASE 0)))
TABLESPACE MEDIUM_VOL_DATA STORAGE (INITIAL 100K NEXT 100K PCTINCREASE 0);
ALTER TABLE LTI_INSTRUCTOR
ADD CONSTRAINT LTI_INSTRUCTOR_PK
PRIMARY KEY (INST_ID);
-- * Step 3: Create the directory for the photos *
CREATE DIRECTORY PHOTOS AS 'C:\InstructorPhotos';
-- * Step 4: Create the procedure to insert a row into the table including the photo *
CREATE OR REPLACE PROCEDURE INSERT_LTI_INSTRUCTOR
(V_INST_ID IN LTI_INSTRUCTOR.INST_ID%TYPE
,V_INST_LNAME IN LTI_INSTRUCTOR.INST_LNAME%TYPE
,V_INST_FNAME IN LTI_INSTRUCTOR.INST_FNAME%TYPE
,V_PHOTO_FILE IN VARCHAR2) IS
FILELOC BFILE;
LOCBLOB BLOB;
LEN INT;
E_BLOB BLOB;
BEGIN
FILELOC := BFILENAME('PHOTOS', V_PHOTO_FILE);
E_BLOB := EMPTY_BLOB();
INSERT INTO LTI_INSTRUCTOR VALUES (V_INST_ID, V_INST_LNAME, V_INST_FNAME, E_BLOB)
RETURNING INST_PHOTO INTO LOCBLOB;
DBMS_LOB.FILEOPEN(FILELOC);
LEN := DBMS_LOB.GETLENGTH(FILELOC);
DBMS_LOB.LOADFROMFILE(LOCBLOB,FILELOC,LEN);
DBMS_LOB.FILECLOSEALL();
COMMIT;
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(-20999, SQLERRM);
END;
-- * Step 5: Create a function to return the lenth of the BLOB field by reading it *
CREATE OR REPLACE FUNCTION INST_PHOTO_SIZE
(V_INST_ID LTI_INSTRUCTOR.INST_ID%TYPE)
RETURN NUMBER
IS
SRCH_LOB BLOB;
BUFFER RAW(16384);
AMOUNT BINARY_INTEGER := 16384;
POS INTEGER := 1;
COUNTER INTEGER := 1;
TOTAL_BYTES INTEGER;
BEGIN
SELECT INST_PHOTO
INTO SRCH_LOB
FROM LTI_INSTRUCTOR
WHERE INST_ID = V_INST_ID;
IF SRCH_LOB IS NOT NULL THEN
     LOOP
DBMS_LOB.READ (SRCH_LOB, AMOUNT, POS, BUFFER);
POS := POS + AMOUNT;
COUNTER := COUNTER + 1;
END LOOP;
ELSE
TOTAL_BYTES := NULL;
END IF;
RETURN TOTAL_BYTES;
EXCEPTION
WHEN NO_DATA_FOUND THEN
TOTAL_BYTES := POS;
RETURN TOTAL_BYTES;
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(-20999, SQLERRM);
END;
-- * Step 6: Insert rows including photos into table and confirm data entry *
-- * Note: The photos are in the directory (case sensitive) defined in Step 3. *
EXECUTE INSERT_LTI_INSTRUCTOR(1001,'WEAVER','LLOYD','Lloyd.JPG');
EXECUTE INSERT_LTI_INSTRUCTOR(1002,'EVIL','LLOYD','lloyd-evil.jpg');
EXECUTE INSERT_LTI_INSTRUCTOR(1003,'SHELTON','CONNIE','Connie.JPG');
EXECUTE INSERT_LTI_INSTRUCTOR(1004,'SMITH','DOUG','Doug.JPG');
SELECT INST_ID, INST_LNAME, INST_FNAME, INST_PHOTO_SIZE(INST_ID) PHOTO_BYTES
FROM LTI_INSTRUCTOR;
I want to display the BLOB column on a asp web page but cannot get it to recognize the BLOB column back as a picture. Since this is being used to demo uses of PL/SQL, I would like to keep it all as SQL or PL/SQL
The asp page looks like the following...it selects the row from the table based on the instructor selected from another pane. (ORCLConnectORA4 is an ODBC connection)
<%
Const lcDBName = "ORCLConnectORA4"
%>
<html>
<body text="#000000" bgcolor="#FFFFFF" link="#CC9900" vlink="#CC9900" alink="#EE1111">
<%
lID=Request.form("EmployeeSelection")
Set lConn = Server.CreateObject("ADODB.Connection")
lConn.ConnectionString = "DSN=" & lcDBName & ";UID=ORA4;PWD=ORA4"
lConn.Open
lSQL = "SELECT INST_FNAME, INST_LNAME, INST_PHOTO from LTI_INSTRUCTOR where INST_ID = " & lID
Set lRS = lConn.Execute(lSQL)
%>
<table border="1" cellspacing="0" width=80% align="center">
<%
lRows = 0
On Error Resume Next
lRS.MoveFirst
lRows = lRows + 1
lFNAME = lRS.Fields("INST_FNAME").Value
lLNAME = lRS.Fields("INST_LNAME").Value
lPHOTO = lRS.Fields("INST_PHOTO").Value
     lConn.Execute(lSQL)
%>
<tr>
<td <%=lBGColor%> align="left" bgcolor="#990000" width="150"><font color="#FFFFFF" size="4"><strong><small>Employee ID</small></strong></font></td>
<td <%=lBGColor%> align="left" bgcolor="#CCCCCC"><b><font size="4" color="#990000"><small><%=lID%>
</small></font></b></td>
</tr>
<tr>
<td <%=lBGColor%> align="left" bgcolor="#990000" width="150"><font color="#FFFFFF" size="4"><strong><small>First Name</small></strong></font></td>
<td <%=lBGColor%> align="left" bgcolor="#CCCCCC"><b><font size="4" color="#990000"><small><%=lFNAME%>
</small></font></b></td>
</tr>
<tr>
<td <%=lBGColor%> align="left" bgcolor="#990000" width="150"><font color="#FFFFFF" size="4"><strong><small>Last Name</small></strong></font></td>
<td <%=lBGColor%> align="left" bgcolor="#CCCCCC"><b><font size="4" color="#990000"><small><%=lLNAME%>
</small></font></b></td>
</tr>
<tr>
<td align="left"><%=lPHOTO%></td>
</tr>
<%
lRS.Close
lConn.Close
%>
</table>
</body>
</html>

Hi,
You've posted this to the web services list. Do you want to use a web service to retrieve the BLOB?
You might want to repost this to another of the forums
rgds
Susan Duncan

Similar Messages

  • Insert/update image in Database from C:\ drive, In BLOB Field using PL/SQL

    is Any Body have a experience of Image file Saving, updating and getting from Table, i want to save it in Database not in any Folder or Link, its Urgent! i want to insert image in Table having BLOB field from C:\test.jpg

    Try the following link, some useful material :-
    http://www-rohan.sdsu.edu/doc/oracle/server803/A50580_2/img_uses.htm

  • How to use Oracle SQL Developer 4.0 to connect to Ms Access file with .accdb extension

    Hi all,
    I am using Oracle SQL Developer 4.0 and Ms Access 2013 under Windows 7 (64 bits)
    After browsing and selecting MS Access file with accdb extention, I got  an error message  :[Microsoft] " Data source name not found and no default driver specified".
    On Administravitve Tools=> ODBC Data Source Administrator=>Drivers I have                                                File                                date
    Name :                                                                               Version
    Microsoft Acess Driver (*.mdb, *accdb)                                 12.00.4518.1014                                        ACEODBC.DLL                    26/10/2006
    Would you please advise?
    Thank you very much in advance

    That MS Access driver is 64-bit, I think.  If SQL Developer, or JDK is 32-bit you need to use the 32-bit driver.   You can see if you have a 32-bit driver installed using  c:\windows\system32\odbcadm32.exe

  • Downloading BLOB to a file using pl/sql toolkit

    Created an Oracle Reports RDF file using the reports builder (9.0.2.x).
    Uploaded the file into the database in a BLOB column using the following code:
    >>>>
    SET VERIFY OFF
    DECLARE
    p_bfile BFILE ;
    p_blob BLOB ;
    BEGIN
    p_bfile := BFILENAME('CDR_REPORTS', '&1') ;
    INSERT INTO RPTIDE (RPTID, RPTMODULE) VALUES ('&1', EMPTY_BLOB()) RETURNING
    RPTMODULE INTO p_blob ;
    DBMS_LOB.FILEOPEN(p_bfile, DBMS_LOB.FILE_READONLY);
    DBMS_LOB.LOADFROMFILE(p_blob, p_bfile, DBMS_LOB.GETLENGTH(p_bfile));
    DBMS_LOB.FILECLOSE(p_bfile);
    COMMIT ;
    END ;
    <<<<<
    Now when we try to download the same file using pl/sql web toolkit (code pasted
    below), the file downloads fine (with exact same file size as before), but no
    longer can open the file in Reports Builder anymore. Get "Cannot open file"
    error in reports builder. Is it getting corrupt or am I doing something wrong?
    >>>>
    CREATE OR REPLACE PROCEDURE filedownload(p_rpt IN VARCHAR2) AS
    p_file blob;
    p_mime_type varchar2(50);
    p_offset integer := 1;
    p_len number;
    p_buf RAW(32000);
    p_buf_size integer:= 32000;
    BEGIN
    SELECT rptmodule, 'application/x-zip'
    INTO p_file, p_mime_type
    FROM rptide
    WHERE rptid = p_rpt ;
    OWA_UTIL.MIME_HEADER(p_mime_type);
    p_len := DBMS_LOB.GETLENGTH(p_file);
    WHILE p_offset < p_len LOOP
    DBMS_LOB.READ(p_file, p_buf_size, p_offset, p_buf);
    HTP.PRN(UTL_RAW.CAST_TO_VARCHAR2(p_buf));
    p_offset := p_offset + p_buf_size;
    END LOOP;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN HTP.PRN('No document specified') ;
    WHEN OTHERS THEN HTP.P('filedownload: '||SQLERRM);
    END filedownload ;
    <<<<<

    The answer to this problem was to set the NLS_LANGUAGE for the DAD to an 8-bit character set since the database charset was 8-bit. It seems, by default, the web toolkit assumes a 7-bit character set.

  • Bulk loading BLOBs using PL/SQL - is it possible?

    Hi -
    Does anyone have a good reference article or example of how I can bulk load BLOBs (videos, images, audio, office docs/pdf) into the database using PL/SQL?
    Every example I've ever seen in PL/SQL for loading BLOBs does a commit; after each file loaded ... which doesn't seem very scalable.
    Can we pass in an array of BLOBs from the application, into PL/SQL and loop through that array and then issue a commit after the loop terminates?
    Any advice or help is appreciated. Thanks
    LJ

    It is easy enough to modify the example to commit every N files. If you are loading large amounts of media, I think that you will find that the time to load the media is far greater than the time spent in SQL statements doing inserts or retrieves. Thus, I would not expect to see any significant benefit to changing the example to use PL/SQL collection types in order to do bulk row operations.
    If your goal is high performance bulk load of binary content then I would suggest that you look to use Sqlldr. A PL/SQL program loading from BFILEs is limited to loading files that are accessible from the database server file system. Sqlldr can do this but it can also load data from a remote client. Sqlldr has parameters to control batching of operations.
    See section 7.3 of the Oracle Multimedia DICOM Developer's Guide for the example Loading DICOM Content Using the SQL*Loader Utility. You will need to adapt this example to the other Multimedia objects (ORDImage, ORDAudio .. etc) but the basic concepts are the same.
    Once the binary content is loaded into the database, you will need a to write a program to loop over the new content and initialize the Multimedia objects (extract attributes). The example in 7.3 contains a sample program that does this for the ORDDicom object.

  • Cannot access class oracle.sql.BLOB;

    Hi,
    I am trying to save a .tif file into Oracle database. When I run the program in JDeveloper I get the following errors:
    Error(9,19): cannot access class oracle.sql.BLOB; file oracle\sql\BLOB.class not found
    Error(59,29): class BLOB not found in class mypackage1.ImageUpload
    package mypackage1;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.sql.*;
    import java.util.Properties;
    import oracle.sql.BLOB;
    Blob imgblob = rs.getBlob(1);
    OutputStream blobos = ((BLOB) imgblob).getBinaryOutputStream();
    ...................Any help is appreciated. Thanks

    What package do I need to include in my classpath for
    this. ThanksWhy don't you inspect your JAR files? Do you have WinZip? Open them with it and find the class.

  • I want to use the SQL query IF EXIST to update or insert data in a ms access table, but it doesn´t work

    Hi,
    I want to use the SQL query IF EXIST to update or insert data in a ms access table, but it doesn´t work
    (fault number -2147217900)
    I want to search for a value in a ms access table , if it exist i want to update it, if not i want to insert a new row.
    Working with LabView 7.1, database con. toolset.
    Who can HELP?
    Thanks a lot
    Marco

    Hello,
    I think that If exist is not a standar SQL command (I know it exists I think in Oracle and SQL server), MS access doesn't support it, so I think the best way to do it is first make a Select and then either an Update or an insert, sorry...
    Paulo

  • Accessing MySQL InnoDB tables via JDBC using Oracle SQL Developer

    I had posted a problem in the Oracle SQL Developer forum with how that application (v1.1) accesses MySQL InnoDB tables and someone replied that the "[data migration] team created the integration with MySQL", so I am posting here in hopes of learning more about the problem.
    Here's a summary:
    When I use Oracle SQL Developer to query MySQL InnoDB tables, I need to issue a "commit" before I do each query to ensure that I am getting current results. Otherwise, it appears to be using a snapshot as-of the last commit. Is this a problem with SQL Developer, or a JDBC configuration, or MySQL problem even?
    The full details are here:
    Re: MySQL InnoDB tables

    Hi,
    I've posted a response to your original thread.
    Regards,
    Dermot.

  • How to get oracle 9i blob column into an itab  in sap using Native SQL

    Hi ,
    We are using SAP ECC 5.0  and we need to coonect to an oracle database ver 9i rel2.
    We need to get the data stored in a blob(pdf/jpeg) into an itab and later
    use it for futher processing.
    I am familiar with using native SQL and I wrote a stored procedure in the non sap oracle database to send the blob info into an internal table in sap.
    But the information is in hex format and the long raw of SAP does not handle this very well.
    Plz see my code below.
    data: itab_insp_drawing like zpicture_cluster(which is of type lraw - 7902 )
          occurs 100 with header line.
    EXEC SQL.
        EXECUTE PROCEDURE
           proc_get_insp_drawings  (
                   IN  :itab-aq_id,
                   IN  :itab-section_id,
                   IN  :t_in_position,
                   out :itab_insp_drawing-picture,
                   OUT :t_blob_length,
                   out :t_out_position,
                   OUT :t_status  )
       ENDEXEC.
      append itab_insp_drawing.
      while t_out_position < t_blob_length.
       EXEC SQL.
        EXECUTE PROCEDURE
           proc_get_insp_drawings  (
                   IN  :itab-aq_id,
                   IN  :itab-section_id,
                   IN  :t_in_position,
                   out :itab_insp_drawing-picture,
                   OUT :t_blob_length,
                   out :t_out_position,
                   OUT :t_status  )
       ENDEXEC.
       append itab_insp_drawing.
       endwhile.
    Any ideas of how to handle blobs from non sap oracle table. I need this blob into an itab in sap.
    Help appreciated.
    Thanks
    Mala

    Please refer the example in this link which deals with Oracle date format.
    You can finnd a command DECODE which is used for date formats. If you have a look at whole theory then you will get an idea.
    Link:[Bulk insert SQL command to transfer data from SAP to Oracle|http://sap.ittoolbox.com/groups/technical-functional/sap-dev/bulk-insert-sql-command-to-transfer-data-from-sap-to-oracle-cl_sql_connection-3780804]

  • Are there any risks to use native sql in ABAP to access external DB

    here is a requirement to use native sql in abap program to access external DB to load some data into sap. Are there any risks and effects which SAP not recommend ?
    Can anybody show some official document to me because I want to know some risks and dangerous to report to my manager..thanks very much.

    hi Anversha s 
    thank you for your reply
    I means what's the risk when to use native sql to access external DB..
    can you show me some examples about open sql which is used to access external DB...
    Now I am investigating the technique about the connection
    between SAP (by abap program) and external DB...the supporter suggestion is to use native sql to access external DBs.but my manager is afraid of the risks when to use native sql,So I have to report the effective document (example: SAP official document) to explain  to my manager.
    thanks very much

  • Using HA SQL server For 3rd Party SQL Access

    Is it possible to use the HA SQL server as the access point for SQL stored proceduers on a link
    server instead of the production SQL server. IPCC 4.0

    you can try it out and see if it works however with 4.x we have observer memory leak which crashes the boxes.
    Moreover as this type of scenario has not been tested by Cisco - TAC will state you to remove the setup before troubleshooting.
    Hope this helps
    Regards
    Anuj

  • Using pl/sql to access non-apex HTML items on page

    how would i use pl/sql to access html items on a page. the items are not apex items.
    i want to loop through a set of html items on the page and do a database update on these values. the method i am using to distinguish these items from others on the page is using a custom attribute of type. i am then going to use the id as the primary key for the database.
    using javascript i can traverse through all items however i require to do it in pl/sql. i realise that i could use javascript to put all values in one apex hidden field but this would be sloppy and i want to avoid doing this.

    Hello,
    When a form submits the server never sees any custom attributes one way or the other, (this in any web environment) all anything on the server side will ever see is the value of the form item submitted. The only way to do what you want is to use javascript to collect the extra information and place it in a form item visible to APEX (a regular APEX Item).
    The javascript route isn't a work around its the only way this will work the way you want. In the product itself we use custom attributes in an htmldb: namespace so the attribute does looks like htmldb:something="value", (you should make your own namespace don't use htmldb:)
    I recommend using the namespace on your attributes instead of just shoving it in there as it will be closer to valid html or xhtml, it will still fail validation but at least you have the argument that "Hey xhtml is xml and xml allows for custom namespaces and custom attributes for that namespace so it's still good xml" not that I've ever used the argument or anything.
    Carl
    Message was edited by:
    Carl Backstrom

  • How to insert BLOB datatype image using PL/SQL Procedure and SQL Loader

    Hi,
    How to insert an image into database using PL/SQL Procedure and also how to insert using SQL Loader. Please help by giving sample code and process description.
    Thanks,
    Vijay V

    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:232814159006

  • Using pl/sql in forms to access rs232 information

    Does anyone know how to capture information receved from serial port (example: serial code) using pl/sql with forms.
    THX.

    What you need is a 3rd party comm ocx or ole
    control like SAXCOMM,PDQCOMM etc.
    Once this is loaded on your machine , then using forms goto the programs "import OLE libray interfaces" option and load the commms control you are using. You must choose the events and methods. Once this is done then the programme units should be updated with the procs (methods) you can call.
    I hope this helps.

  • Table does not exist (servlet accessing the postgres sql table)

    Hello every body,
    I am running servlet to access the postgres sql table. But there exist error.
    ERROR: relation "employee" does not exist
    I have checked the table name in database and table name into the servlet. Both are same. Please give me suggestion to solve this error.
    Thanks

    can you connect to the database without the servlet?
    put your stuff into this and try it. If it works, add something to check the table names. - %
    package test;
    import java.sql.Connection;
    import java.sql.DatabaseMetaData;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.Statement;
    * Connect to a database using JDBC
    public class ConnectionTest
       private static final String DEFAULT_DRIVER = "your driver here";
       private static final String DEFAULT_URL = "your url here";
       private static final String DEFAULT_USERNAME = "your username here";
       private static final String DEFAULT_PASSWORD = "your password here";
       public static void main(String[] args)
          Connection connection = null;
          ResultSet rs = null;
          try
             String driver = ((args.length > 0) ? args[0] : DEFAULT_DRIVER);
             Class.forName(driver);
             String url = ((args.length > 1) ? args[1] : DEFAULT_URL);
             String username = ((args.length > 2) ? args[2] : DEFAULT_USERNAME);
             String password = ((args.length > 3) ? args[3] : DEFAULT_PASSWORD);
             connection = DriverManager.getConnection(url, username, password);
             DatabaseMetaData databaseMetaData = connection.getMetaData();
             System.out.println("product: " + databaseMetaData.getDatabaseProductName());
             System.out.println("major  : " + databaseMetaData.getDatabaseMajorVersion());
             System.out.println("minor  : " + databaseMetaData.getDatabaseMinorVersion());
             System.out.println("schemas");
             rs = databaseMetaData.getSchemas();
             while (rs.next())
                System.out.println(rs.getString(1));
          catch (Exception e)
             e.printStackTrace();
          finally
             close(rs);
             close(connection);
       public static void close(ResultSet resultSet)
          try
             if (resultSet != null)
                resultSet.close();
          catch (Exception e)
             e.printStackTrace();
       public static void close(Statement statement)
          try
             if (statement != null)
                statement.close();
          catch (Exception e)
             e.printStackTrace();
       public static void close(Connection connection)
          try
             if (connection != null)
                connection.close();
          catch (Exception e)
             e.printStackTrace();
    }

Maybe you are looking for