How to upload and retrieve text files to/from Database CLOB column?

This Simple Creator 2 Project zip demos how to upload text files into database CLOB column and retrieve back those files.

How to get the sample app running:

  • Download and extract the project zipfile into a directory
  • Create a table DEMO_CLOB in PointBase Order datasource i.e., Invoke View Data on Order Datasource in Servers window. Copy & paste this SQL into the textarea and click RunQuery button to execute the command. This SQL creates the required table in PointBase sample database PBPUBLIC schema.
    CREATE TABLE DEMO_CLOB ( ID_COL INTEGER IDENTITY PRIMARY KEY, CLOB_COL CLOB)
  • Open the project in Creator and Click on Run Main Project (aka Green Arrow) tollbar button
  • Click Browse and choose a text file.
  • Click Upload to updload this into database. It also retrieves back all the rows in this database table and displays using in a table component.
  • What's wired in this project:

    • A ClobConverter class. It is declared in WEB-INF/faces-config.xml and the attribute converter="ClobConverter" is added in JSP to the tableColumn bound to CLOB_COL
    • Upload button action fetches the file contents and updates the database

    screenshot - click to see full size
    Comments:

    Post a Comment:
    Comments are closed for this entry.
    About

    sakthi

    Search

    Archives
    « April 2014
    SunMonTueWedThuFriSat
      
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
       
           
    Today