aspose file tools
The moose likes JDBC and the fly likes ByteArray converted to a String to store in database Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "ByteArray converted to a String to store in database" Watch "ByteArray converted to a String to store in database" New topic
Author

ByteArray converted to a String to store in database

Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
I had a ByteArray converted into a String



where baos is a ByteArrayOutputStream. I was thinking if it's ok to store it in the database(through Java code) this way especially if I'm going to use PreparedStatement... Any help would be appreicated. Thanks guys!


SCJP 1.5
http://devpinoy.org/blogs/lamia/ - http://everypesocounts.com/
stu derby
Ranch Hand

Joined: Dec 15, 2005
Posts: 333
Most databases have a datatype specifically designed for Binary Large OBjects; this datatype is called "BLOB" and is what most people use to store image data in a database.

Most databases have internal limits on the size of character strings supported by the normal string datatypes, but many have an unlimited size string datatype, called CLOB (character large object). For your purposes, if they have CLOB, then almost certainly have BLOB, and you should be using that.

There are examples on the web for how to use these datatypes for images; try Google.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: ByteArray converted to a String to store in database
 
Similar Threads
Convert a date and time to a different time zone
BLOB insertion
storing date in database
Outputting to .txt
read and write file in parts