Assuming you are using ResultSet:
Look into the ResultSet's getBlob methods, then check out Blob's methods. This might take you a whole minute to do and I guarantee you'll find what you want.
[url=http://java.sun.com/j2se/1.5.0/docs/api/]API[/url]s are your friend. You should check them for what you need first (or google), then post here if you cannot find your answer.
This is my exact code
//Connecting database
MyDBConnection mdbc=new MyDBConnection();
mdbc.init();
Connection conn=mdbc.getMyConnection();
try {
Statement stmt= conn.createStatement();
} catch (SQLException ex) {
ex.printStackTrace();
}
// Other code
public void updateDataBase(String data1, byte[] data){
int u = stmt.executeUpdate("insert into myTable (column1) values("
+quotate(data1)+" );");
ResultSet res = stmt.executeQuery("select * from myTable");
res.next();
res.next();
res.getBlob("data").setBytes(1,data);
}
//To easily make quotes
private String quotate(String content) {
return "'"+content+"'";
}
I tried to make it using "Insert":
byte[] data = new byte[]{0x01, 0x02};
int u = stmt.executeUpdate("insert into myTable (column1, blobColumn) values(" +quotate(dato_TX_RX)+", "+data+" );");
the problem is that if I look into the database, in the blob field there is only the memory address of the array.
PreparedStatement pstmt = con.prepareStatement("insert into tablename (columnname) values ( ? )");
pstmt.setBinaryStream(1, in, length);
pstmt.executeUpdate();
Again, you should get in the habit of using only PreparedStatements.
They have many advantages over plain Statements.