Results 1 to 4 of 4
  1. #1
    atom86 is offline Member
    Join Date
    Sep 2009
    Location
    Italy, Turin
    Posts
    39
    Rep Power
    0

    Default BinaryStream with PreparedStatements

    i'm working with binaryStream in prepared statements.
    this is my code (a simpier version):
    Java Code:
    FileInputStream fis = new FileInputStream([COLOR="Green"]myFileBiggerThanJVMHeapMemory[/COLOR]);
    
    {....}//obvious code to set the database connection ignored for simplicity
    
    PreparedStatement ps;
    
    sqlStatement="INSERT INTO `files` VALUES(0,?,?,?,?);"
    
    ps = conn.prepareStatement(sqlStatement, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
    
    ps.setString(1, [COLOR="Green"]myFileBiggerThanJVMHeapMemory[/COLOR].getName());
    ps.setInt(2, myIntID);
    ps.setString(3, myString);
    [COLOR="Red"]ps.setBinaryStream(4, fis, fis.getChannel().size());[/COLOR]
    
    ps.executeUpdate();
    i start saying that this code works fine and insert everything in each DB column without warning , Exception or anything else...

    BUT if the file i'm going to set is bigger than 12-13 MB ... i receive an HeapOutOfMemory.... i thought that binary Streams do not have any limited dimension ...but probably i'm wrong... is it possible to resolve this problem with preparedStatement? or do i need other solutions?

    thanks

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    How much memory are you allocating to the JVM anyway?

  3. #3
    atom86 is offline Member
    Join Date
    Sep 2009
    Location
    Italy, Turin
    Posts
    39
    Rep Power
    0

    Default

    one of this 4 numbers...

    -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m

    in my netbeans.conf i have this 4 values set... can you tell me (if you know) the meanings of this 4 values? which one could be the problem?

    thanks

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •