This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes PreparedStatement, setBinaryStream, and outOfMemoryError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "PreparedStatement, setBinaryStream, and outOfMemoryError" Watch "PreparedStatement, setBinaryStream, and outOfMemoryError" New topic

PreparedStatement, setBinaryStream, and outOfMemoryError

Hans Solo

Joined: Jul 25, 2006
Posts: 2
I'm trying to load very file files into a mysql db, and I'm frustrated. I set up a prepared statement, used setBinaryStream to input the file, and executed only to have the outOfMemoryError bite me.

My understanding given the javadoc is that using the setBinaryStream method will allow me to basically stream the file in rather than holding the entire thing in memory. I point at this line... "The data will be read from the stream as needed until end-of-file is reached"
in the javadoc

Here is the relevant code snippet.

What am I missing here?
Hans Solo

Joined: Jul 25, 2006
Posts: 2
I should point out that the DB in question is MySQL. I believe that may be the problem, but I can't verify it past my assumption that the fault lies there.
I agree. Here's the link:
subject: PreparedStatement, setBinaryStream, and outOfMemoryError
Similar Threads
print korean charater file using java
file download time
How to allocate the memory from OS instead of increasing the JVM’s heap size?
intermittent reading data into a byte[ ]
Read a music file