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.
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.
@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.
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.
@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.
That new kid is a freak. Show him this tiny ad:
a bit of art, as a gift, the permaculture playing cards