4 Replies Latest reply on Apr 19, 2002 3:35 AM by Ben Alex

    usage of BLOB in JBoss 2.4.1 using MySQL

    imran Newbie

      Hello All

      I'm using Jboss, Mysql and am using struts as my MVC framework. I need to store documents in the DB using the BLOB sql type. But How do i store BLOB types. I can get a byte[] containg the data contents using the FormFile class provided in the struts framework. My questions are
      How can i store this byte[] as a BLOB in the DB?.
      How should my configuration in jaws.xml look like?.
      Do i need to write some sought of a wrpper class to do this?.

      Any help is appreciated very much.

        • 1. Re: usage of BLOB in JBoss 2.4.1 using MySQL
          Frank Stolte Newbie

          I'm using this in my standardjaws.xml


          <java-type>java.lang.Object</java-type>
          <jdbc-type>JAVA_OBJECT</jdbc-type>
          <sql-type>BLOB</sql-type>


          I have an entity bean with the two variables

          public String name;
          public ScanningValueObj scanningValueObj;

          The first is the key and the second is a large object which gets stored by JBoss as a MEDIUMBLOB. I'm using CMP. Here is the standardjaws.xml part which creates the table in MySQL. The object is more then 64k in size that's why I'm usig mediumblob.



          <ejb-name>Scanning</ejb-name>
          <cmp-field>
          <field-name>name</field-name>
          <column-name>name</column-name>
          <jdbc-type>VARCHAR</jdbc-type>
          <sql-type>VARCHAR(20)</sql-type>
          </cmp-field>
          <cmp-field>
          <field-name>scanningValueObj</field-name>
          <column-name>scanningValueObj</column-name>
          <jdbc-type>JAVA_OBJECT</jdbc-type>
          <sql-type>MEDIUMBLOB</sql-type>
          </cmp-field>


          Frank

          • 2. Re: usage of BLOB in JBoss 2.4.1 using MySQL
            imran Newbie

            Hi Frank

            Thanx a lot for your reply. And indeed gave me some idea to get started on. But my question now is in the mechanism that you follow what is the "ScanningValueObj". Is it a class that implements the java.io.Serializable and implements the BLOB interface. Have you got any idea how JBOSS is going to interprit the "ScanningValueObj" as a BLOB to be stored in the DB. i.e How it would do the necessary insert/select queries. Please let me know about this, which i think should be good enough for me to get cracking on things.

            TIA

            Imran

            • 3. Re: usage of BLOB in JBoss 2.4.1 using MySQL
              Martin Stepanek Newbie

              Hi Imran,

              did you get some answer to your last question? I have the same problem... If you (or somebody) know the answer, please can you post it here?

              Thanx
              Martin

              • 4. Re: usage of BLOB in JBoss 2.4.1 using MySQL
                Ben Alex Newbie

                Hi there

                I use a class like that described above called BlobHolder. It looks like this:

                public class BlobHolder implements Serializable
                {
                public byte[] content;
                }

                I use a SQL type of BLOB/MEDIUMBLOB/LONGBLOG if I need 64Kb, 16Mb or 4096Mb maximum content sizes respectively with the JDBC type set to JAVA_OBJECT. It works fine.

                Regards

                Ben