• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Uploading a Clob field from Derby Db to a JTABLE within Netbeans 12.5 and GUI Form

 
Ranch Hand
Posts: 79
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys: I have written a program for tracking support calls but now need to load the results from the Derby DB. The fields are CLOBs and I have been able to save them to Derby and display them from Derby to a TextArea entry. However, I now need to display the CLOBs to a JTable entry. The below is a method I have so far done and it does load the Clobs but not as string data.  Instead I get "org.apache.derby.impl.jdbc.EmbedClob@55443010 , org.apache.derby.impl.jdbc.EmbedClob@3e784536, and so on" for each field entry which, I understand to be the definitions of the Clobs as stored in the database. Loading directly from the database as a ResultSet is pretty straight forward-- but loading it using DbUtils doesn't allow for converting to a string text. I need to be able to display the text of each CLOB within the JTable. Any help would be appreciated. I fully understand that outside of Netbeans one can write great code --however, I need to continue using the GUI Form Displays. The below method is run from a jbutton (external to the method) and it displays the results to a table    jtbl_CategoryList.

 
Sheriff
Posts: 28371
99
Eclipse IDE Firefox Browser MySQL Database
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me first suggest that wrapping your test code in a Swing wrapper will just add a layer of confusion. Start by writing some ordinary code which reads data from a database and writes it to the console.

And second, the Clob interface has various methods like length() and getSubstring() and getCharacterStream() which enable you to extract data from a Clob. You've got the getClob() method in your ResultSet. So use those methods to get ahold of the String data.
 
Bill Melendez
Ranch Hand
Posts: 79
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Paul: Thanks for the great advice! I relooked at the whole setup and decided that I could use LONG VARCHAR instead of Clob. LONG VARCHAR allows up to 35K length --which is more than ample storing space for the different entries within the Phone Log program. It also made retrieving the data from the Derby DB much easier since JTABLE uses STRING and the method I coded really is critically tied to a String ResultSet. I didn't have to do any conversions from Clob to String.  
 
Paul Clapham
Sheriff
Posts: 28371
99
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bill Melendez wrote:I relooked at the whole setup and decided that I could use LONG VARCHAR instead of Clob.



Excellent idea! I've never used Clob myself -- I imagine it could be useful if you're storing a chapter of a novel in a database cell, or something like that, but just plain text has always been fine for my requirements.
 
Saloon Keeper
Posts: 28486
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've used CLOB for a system that stored a lot of legal stuff in Rich Text Format.

But where possible, a String is preferable.
 
Bill Melendez
Ranch Hand
Posts: 79
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@All:  Aft,er solving my issue with Clob into Derby by using the LONG VARCHAR, and then loading this LONG VARCHAR to a JTable, I looked at adding the line wrap (setLineWrap(true)) to the rows but found it somewhat too complicated. For the time being, I instead used textareas to display the slected row data. Below is the simple Table_Click method I used by adding the mouse click event to the table. I hope someone out there can benefit from my own trial and error experience. NOTE: I added a public String to problemSearch, troubleshootSearch, resolutionSearch, and codeSearch. The parameter variable rowrec took a public Integer.

 
These are not the droids you are looking for. Perhaps I can interest you in a tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic