Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Importing Binaries from MySql to Oracle
Hi everyone.
I changed the database of an application from MySql to Oracle. The App
is a java application. I fixed all queries, etc. so the application is
running without errors. Except one.
In this application several PDFs are generated and stored in Database
as BLOBs. Because there are some important Records in the old MySql
Database, i programmed a little Java Application, that imports the old
Database to MySql. Works without errors.
But if I want to open a PDF file in the application, that was imported
from MySql, i get the following Error:
File does not start with "%PDF-".
All other PDFs, that were stored in database with the new Oracle Application are ok and can be viewed. Do you have any clue, what the problem could be? I'll paste my import code, so you can see how it's done:
Statement drks_stm = mysql.createStatement();
ResultSet drks_rs = drks_stm.executeQuery("SELECT drknummer, pdf FROM
REE_DRUCKE");
System.out.println("SELECT drknummer, pdf FROM REE_DRUCKE");
while(drks_rs.next()) {
int drknummer = drks_rs.getInt("drknummer");
byte[] data1 = drks_rs.getBytes("pdf");
int drknummer = drks_rs.getInt("drknummer");
byte[] data = drks_rs.getBytes("pdf");
Statement del_stm = orcl.createStatement();
del_stm.executeUpdate("UPDATE REE_DRUCKE SET pdf=empty_blob() WHERE
drknummer="+drknummer);
System.out.println("UPDATE REE_DRUCKE SET pdf=empty_blob() WHERE
drknummer="+drknummer);
del_stm.close();
Statement ins_stm = orcl.createStatement();
if(data != null)
{
byte[] buffer = data;
orcl.setAutoCommit(false);
Statement blb_stmt = orcl.createStatement();
ResultSet blb_rs =(ResultSet) blb_stmt.executeQuery("SELECT pdf FROM
REE_DRUCKE WHERE drknummer='"+drknummer+"' FOR UPDATE");
if(blb_rs.next())
{
BLOB blob = ((OracleResultSet)blb_rs).getBLOB(1);
OutputStream outstream = blob.getBinaryOutputStream();
outstream.write(buffer);
outstream.close();
System.out.println("BLOB UPDATED!");
}
blb_stmt.close();
blb_rs.close();
orcl.setAutoCommit(true);
}
}
Thanks in advance. Received on Mon Apr 25 2005 - 11:07:58 CDT
![]() |
![]() |