********* Btr32Java Sample Java Application Accessing Data of LONGVARBINARY type Copyright @ Pervasive Software, Inc. March, 2003 ********* Sample demonstrating the usage of LONGVARBINARY type **************************************************** Table Of Contents * Overview of the Sample Application * Required Software * Application Set-up and Configuration * Description of Sample Files Overview of the Sample Application ********************************** This application shows how to perform inserts, delete and retrieval from a LONGVARBINARY column in Java. The sample uses the Pervasive.SQL JDBC driver and JCL (Java Class Library). This sample application simulates a customer record display in which the customer information, ID, Name and Company as well as a picture of company log, are displayed by the application. The sample application uses two database tables, Customer and Graphic. The pictures are stored in a column of LONGVARBINARY type in table, Graphic. Records in Table, Customer, are always retrieved by using JDBC. Initially, there are 200 rows in Customer Table. Records in Table, Graphic, can be manipulated in two ways, either through JDBC or JCL. By default, JCL is used. It can be changed at the run time through a check button. Not all customer records have a picture record in the Graphic Table. Pictures of Customer Records can be inserted, delete and updated. When the application is invoked, Customer records are retrieved and display. The status of each action is shown in the status bar. Errors if any, are also shown in the status bar. When a specific customer record is selected in the JList, a picture, if there is one, is displayed. Each of the functions, getCustomerGraphic, deleteCustomerGraphic and doUpdateGraphic, of class, Btr32Func, has a control structure if ( m_useJDBC == false ) { // code using JCL } else { // code using JDBC } The TRUE branch is implemented by using JDBC on LONGVARBINARY column while the FALSE branch is implemented by using JCL. JCL is an Java wrapper of navigational Btrieve API. To manipulate the LONGVARBINARY column in JCL, Chunk operations are used while in JDBC, InputStream class is used. Required Software ***************** * Pervasive.SQL V8 SP1 * Pervasive.SQL JDBC Driver included in Pervasive.SQL V8 SP1 * Pervasive.SQL V8 SDK (can be down loaded from http://wwww.pervasive.com/ Application Set-up and Configuration ************************************ * Extract database directory, Data and all files under it Create a database, e.g., Btr32SampleDB, at the extracted directory, Data. Do not create DDFs Create a system DSN, e.g., Btr32SampleDSN, using the database at the previous step as DBQ * Extract Btr32Java.properties, Btr32Java.class and Btr32JCL.jar Add the path of Btr32JCL.jar into CLASSPATH environment variable * Edit Btr32Java.properties file. Replace , , and with actual values dbURL=jdbc:pervasive:/// BTRFILE=/Graphic.mkd logFile=/Btr32Java.log Description of Sample Files *************************** ReadMe.txt - This file. Btr32Java.properties - This file has the details of the database connection parameters and other application settings. Btr32Java\Btr32Command.java - \Btr32Frame.java - source for the sample User Interface \Btr32Func.java - source for the sample data access \Btr32Java.java - main function of the sample \CustomerCellRender.java - Customized JList cell render \ImageFileFilter.java - Customized FileFilter Btr32Java\AppObj\CustGraphic.java - source of manipulating binary graphic using JCL \Customer.java - Java class of Customer records Btr32Java\db\BtrObj.java - Simple wrapper of SCursor class of JCL \*.java - Java classes of implementation of simple connection pool Btr32Java\util\Btr32JavaParams.java - \Logger.java - source of logging class \SwingWorker.java - source of 3rd version of SwingWorker (also known as SwingWorker 3), an abstract class that can be subclassed to perform GUI-related work in a dedicated thread. Downloaded from http://java.sun.com/ data\*.ddf - Pervasive.SQL relational data dictionary file \Customer.mkd - Btrieve data file of Customer table \Graphic.mkd - Btrieve data file of Graphic table ======= This sample was tested using Pervasive.SQL V8. All source code herein contained is supplied without any warranty or support. This code is meant for your educational use to get you started in developing code to suit your needs.