3 Replies Latest reply on Jul 7, 2004 4:26 AM by oberkom

    JBOSS, JDBC, and BLOBs

    bill mallian Newbie

      I have an implementation where we are connecting to an Oracle 9 database through JBOSS using an oracle thin client connection.

      I have code which reads a .jpg file into a byte array, and I then populate a BLOB field in my Oracle database with the byte array. (This is done by the JBOSS setter method).

      Anyhow, I notice that if the .jpg file is under 2k, it stores it in Oracle no problem. But if the file is greater than 2k, it does not store the file in Oracle and no errors are generated.

      Are there any limitations in JBOSS or JDBC that is limiting me to 2k, supposedly BLOB datatypes in Oracle can hold up to 4 gig of info ??

      or any workarounds ????

      Thanks in advance for your help.

        • 1. Re: JBOSS, JDBC, and BLOBs
          oberkom Newbie

          I had a similar problem, i used a binary stream to load the images at the database, like:

          PreparedStatement prepStmt = null;
          try {
          
           makeConnection();
           String strInsertSQL = "INSERT INTO TABLEBLO (BLOINTNUM,BLO__FILE) VALUES (?,?)";
           prepStmt = con.prepareStatement(strInsertSQL);
          
           strIdentifier = getId(); // Getting new id
           prepStmt.setString(1,strIdentifier);
          
           ByteArrayInputStream bais = new ByteArrayInputStream(arrayArchivo);
           prepStmt.setBinaryStream(2, bais,arrayArchivo.length);
           prepStmt.executeUpdate();
          
           bais = null; strInsertSQL = null;
          
          } catch (Exception e) { <whatever> );
          } finally {
           prepStmt.close();
           closeConnection();
          }


          I hope this helps you

          • 2. Re: JBOSS, JDBC, and BLOBs
            bill mallian Newbie

            well, i tried your implementation, but i'm still limited to 2k. if my file is under 2k it inserts no problem, over 2k it doesnt insert.

            what is your variable arrayArchivo ??? is that a byte[] array ??

            you are using the Oracle thin client along with Oracle 9 ???

            • 3. Re: JBOSS, JDBC, and BLOBs
              oberkom Newbie

              Correct,

              arrayArchivo its the file byte array i want to load into database... Iam using Oracle 8.1.7. to load that blob into a LONG RAW field....