Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Need help with storing large text in derby db

 
Ranch Hand
Posts: 103
2
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, ranch!

I am working on a application that allows the user to store a very large amount of text ( a job seeking application ). I am not new to the derby database but have never used the Blob data type that it supports. I am struggling very hard to understand how the Blob data type works. It is very different from the basic setString method.

I have a JTextArea in my application and wan't to save the text from that component in to a Blob and then read from it but this is above my current level of knowledge so I am asking for a little help here.

I have tried something like this but this is obviously not working, since I am a Blob-newbie!



and then ...



I am wondering if anyone could show me how this is done in the the real world? This is quite urgent for me since I am working against a deadline so any help is greatly much appreciated in advance and thanks to all that have taken their time to read this post!

Best regards and wishes,
Robert!




 
author & internet detective
Posts: 39675
785
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's been a while since I've done blobs in a RDBMS so googled to find an example that looks similar to how I remember it working. This one looks familiar.
 
Master Rancher
Posts: 4371
47
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's text then I would suggest using a CLOB.

There's an example here:
https://db.apache.org/derby/docs/10.2/ref/rrefclob.html

(Apologies if the version is old)
 
Robert Ingmarsson
Ranch Hand
Posts: 103
2
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I clobbed this!

Best Mr, Tolls! Sorry for a late reply! I finally found the solution for this problem. After a bit reading I just find out that using a Clob is a better choice for storing large text than a Blob.
Here is my solution and first the setClob code part:



And this is how i extract the text from the current clob object:



Best regards and wishes,
Robert!




 
You may have just won ten million dollars! Or, maybe a tiny ad.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!