how to Reading PDF saved in oracle Database long type
i used this way
try {
String sql="SELECT PDF_FILE FROM MF04S2 WHERE FUNDTYPE='"+FundType+"' AND FCODE='"+fcode+"'";
PConnection pConn = new PConnection("test", "test");
conn = pConn.connect();
String sql="SELECT PDF_FILE FROM MF04S2 WHERE FUNDTYPE='"+FundType+"' AND FCODE='"+fcode+"'";
PConnection pConn = new PConnection("test", "test");
conn = pConn.connect();
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
rs = stmt.executeQuery(sql);
if (rs.next ())
{
try
{
FileOutputStream file = new FileOutputStream(filepath);
InputStream fin = rs.getBinaryStream (1);
int c;
while ((c = fin.read ()) != -1)
file.write (c);
file.close();
}
catch (FileNotFoundException fe)
{
System.err.println ("thrown: java.io.FileNotFoundException\n");
fe.printStackTrace ();
System.err.println (fe.getMessage ());
} catch (IOException ioe)
{
System.err.println ("thrown: java.io.IOException\n");
ioe.printStackTrace ();
System.err.println (ioe.getMessage ());
}
} // if (rset.next)
{
try
{
FileOutputStream file = new FileOutputStream(filepath);
InputStream fin = rs.getBinaryStream (1);
int c;
while ((c = fin.read ()) != -1)
file.write (c);
file.close();
}
catch (FileNotFoundException fe)
{
System.err.println ("thrown: java.io.FileNotFoundException\n");
fe.printStackTrace ();
System.err.println (fe.getMessage ());
} catch (IOException ioe)
{
System.err.println ("thrown: java.io.IOException\n");
ioe.printStackTrace ();
System.err.println (ioe.getMessage ());
}
} // if (rset.next)
}
catch (Exception e)
{
e.printStackTrace();
}
catch (Exception e)
{
e.printStackTrace();
}
this way result ..... data error
