120 likes | 240 Views
CS276 Advanced Oracle Using Java. Large Objects Chapter 8. The Example Files.
E N D
CS276 Advanced Oracle Using Java Large Objects Chapter 8
The Example Files Some of the examples read files and store their contents in the database, but the contents of a LOB doesn’t have to come from a file – the content can come from any valid source that your Java program can read as astring of characters or bytes. • textContent.txt • binaryContent.doc
Large Objects(LOBs) JDBC supports three large object types: • CLOB The Character LOB type • BLOB The Binary LOB type • BFILE The Binary FILE type, which is used to store pointers to files located in the file system. You can read the contents of the actual file via a BFILE pointer in a Java program. These external files can be on a hard disk, a CD, a DVD and etc.
Large Objects(LOBs) LOBs consist of two parts: • The LOB locator • A pointer that specifies the location of the LOB content • The LOB content • The actual character or byte data stored in the LOB
Large Objects(LOBs) The Example Tables: • clob_content • clob_column is used to store the character data contained in the textContent.txt • blob_content • blob_column is used to store the binary data contained in the binaryContent.doc • bfile_content • is used to store pointer to the two exetrnal files
The Put, Get, and Stream Methods When working with LOBs using JDBC, you need to create a LOB object. It is through this LOB object that you access a LOB column. The Oracle.sql package contains: oracle.sql.CLOB oracle.sql.BLOB oracle.sql.BFILE
Using the Put Methods to Write to CLOB and BLOB Columns LobExample1.java This program contains the following methods: writeCLOB()writeBLOB() writeBFILE()
Using the Streams to Write to CLOB and BLOB Columns • LobExample3.java
Using the GetMethods to Read from CLOB and BLOB Columns LobExample2.java it shows how to read from CLOB and BLOB columns and how to read external files pointed to by BFILE columns This program contains the following methods: readCLOB()readBLOB() retrieveBFILE()
LONG and LONG RAW Columns We use two new tables: • long_content • long_raw_content
Writing to LONG and LONG RAW Columns You can use eight steps to use a stream to write to… LongExample1.java
Reading from LONG and LONG RAW Columns You can use eight steps to use a stream to write to… LongExample2.java