EMPTY_BLOB() problem while serialization
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Tuesday, May 14, 2002 12:52 AM

hiho, when i try to serialize an image and store it in an oracle database, the value that is inserted is always "null". why??? try { s.executeUpdate("create table authorinfo(authorinfoid NUMBER(10) PRIMARY KEY, authordate DATE, authorname VARCHAR2(255), action VARCHAR2(255), authorcomment VARCHAR2(255))"); s.executeUpdate("create table image(imageid NUMBER(10) PRIMARY KEY, image BLOB, imagename VARCHAR2(255), imageinfo NUMBER(10))"); s.executeUpdate("create table reportlist(reportid NUMBER(10) PRIMARY KEY, reportname VARCHAR2(255), reportcomment VARCHAR2(255), reportinfo NUMBER(10))"); authorinfoidcounter = 1   More>>


hiho,


when i try to serialize an image and store it in an oracle database, the value that is inserted is always "null".

why???


try

{
s.executeUpdate("create table authorinfo(authorinfoid NUMBER(10) PRIMARY KEY, authordate DATE, authorname VARCHAR2(255), action VARCHAR2(255), authorcomment VARCHAR2(255))");

s.executeUpdate("create table image(imageid NUMBER(10) PRIMARY KEY, image BLOB, imagename VARCHAR2(255), imageinfo NUMBER(10))");

s.executeUpdate("create table reportlist(reportid NUMBER(10) PRIMARY KEY, reportname VARCHAR2(255), reportcomment VARCHAR2(255), reportinfo NUMBER(10))");


authorinfoidcounter = 1;

iidcounter = 1;


s.executeUpdate("insert into authorinfo values(" + authorinfoidcounter + ", '" + textField4.getText() + "', '" + textField7.getText() + "', '" + textField9.getText() + "', '" + textField12.getText() + "')");

s.executeUpdate("insert into image values(" + iidcounter + ", EMPTY_BLOB(), '" + textField17.getText() + "', " + authorinfoidcounter + ")");

s.executeUpdate("insert into reportlist values(" + textFieldn.getText() + ", '" + textField2.getText() + "', '" + textField3.getText() + "', " + authorinfoidcounter + ")");


try

{


con.setAutoCommit(false);


//s.executeUpdate("update image set image = EMPTY_BLOB()");

s.executeUpdate("select image from image where imageid = " + iidcounter + " for update");


File file = new File(dir + filename);

FileInputStream fis = new FileInputStream(file);


PreparedStatement pstmt = con.prepareStatement("update image set image=? where imageid=" + iidcounter);

//PreparedStatement pstmt = con.prepareStatement("insert into image (image) values (?)");

pstmt.setBinaryStream(1, fis, (int)file.length());

//pstmt.setString(2, dir + filename);

pstmt.executeUpdate();

pstmt.close();


fis.close();


}

catch (IOException ioe){



ioe.printStackTrace();


}

catch (SQLException sqle)
{


sqle.printStackTrace();


}


}

catch (SQLException sqle){......}

   <<Less
About | Sitemap | Contact