tags:

views:

63

answers:

1

The table columns have the data type BLOB and CLOB.

What are the corresponding Java data types?

I am using MySQL database.

A: 

BLOB and CLOB are bytes strings stored in database.

In MySQL, you can have an entity with a field of byte array representing your BLOB / CLOB.

E.g.

class MyBlob implements Serializable {

  byte[] myBlobField;

  //Setter
  public void setMyBlobField(byte[] myBlobField) {
    this.myBlobField = myBlobField;
  }

  //Getter
  public byte[] getMyBlobField() {
     return myBlobField;
  }
}

On JDBC, create a PreparedStatement and do something of this effect:

 MyBlob blob = ....;
 PreparedStatement ps = ....;
 ps.setByte(1, blob.getMyBlobField());

 ps.execute();
 //Handle Exceptions...close...etc.
The Elite Gentleman
Thanks For the answer:)
Dj
You're welcome.. :)
The Elite Gentleman