RE: Finding the size of a BLOB
"Paul-Benoit Larochelle" <[email protected]> Tue, 5 Sep 2006 23:51:21 -0400
| Newsgroups | gmane.comp.db.mckoi |
|---|---|
| Message-ID | <001001c6d167$bb6394a0$6801a8c0@acerd18848db56> |
I have found a way.... I serialize myself the JPanel by writting it to a ByteArrayOutputStream Then I can get the ByteArrayOutputStream byte[] .length I put the byte[] in the BD Read back the byte[] from the BD Read back the JPanel with a ByteArrayInputStream(byte[]) -----Original Message----- From: Paul-Benoit Larochelle [mailto:[email protected]] Sent: Monday, September 04, 2006 20:29 To: '[email protected]' Subject: Finding the size of a BLOB 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