Finding the size of a BLOB

"Paul-Benoit Larochelle" <[email protected]> Mon, 4 Sep 2006 20:29:24 -0400
Newsgroups gmane.comp.db.mckoi
Message-ID <001601c6d082$5a300460$6801a8c0@acerd18848db56>
Hello all,
 
I have an application which must display hugue reports in a JTabbedPane
Reports are presented with JTable in the scrollPane of a JPanel
The fastest way I found after many trials is to generate the JTables in
a thread when the application is started, to create the JPanel and to
store the JPanel  as a Java object in a table.
When the user want to see a report, the application retreives the JPanel
and add it to the JTabbedPane.
 
This works fine... McKoi is great !!!
 
Now, some reports are hugue:  12,000 rows, 20 columns. So I would like
to present a ProgressBar, in a thread,  while the application is
retreiving the JPanel from the database....  I guess that after some
tests ans trials I could guess how long it takes to retreive a JPanel of
xxxMB from the database but for that I need the size of the serialized
JPanel... how can I achieve that ?
 
The easiest way would be to store in the table row the size of the
JPanel serialized object:
 
Create Table Reports (Obj JAVA_OBJECT, Id INTEGER, BlobSize INTEGER);
 
PreparedStatement insert = connection.prepareStatement("Insert Into
Reports (Obj, Id, BlobSize) Values(?, ?, ?)");
 
void sqlInsert(JPanel panel, int id) {
            try {
                        insert.setObject(1, panel);
                        insert.setInt(2, id);
                        insert.setInt(3, .......... what is the Blob
size ??????????????);
            }
}
 
then when I will retreive the JPanel I would first fetch the BlobSize
("Select BlobSize from Reports where Id = ?" from the row and start a
thread to display the ProgressBar according to the size of the JPanel
 
I guess that this is trivial for some of the SQL gurus around
 
Thanks
Paul-Benoit