Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> JSP & Oracle InterMedia

JSP & Oracle InterMedia

From: Andreas Stroeber <andreas.stroeber_at_fthw.STOP_SPAM_siemens.TLDde>
Date: Mon, 29 Nov 2004 17:26:43 +0100
Message-ID: <cofik3$c7g$5@mail1.sbs.de>


Hi NG,

I have got a (big?) problem with Oracle Intermedia. What i want to do is:

  1. Get a PDF File that was sent via form POST on a html page.
  2. Save this PDF to the database.
  3. Search the database for keywords and get results when the keyword exists in the pdf file.

I know that this should work with intermedia and Java Server Pages (JSP). My first problem at the moment is: How to save the PDF file into the database?

Mainly i have the problem that needed functions are not present in the java.sql classes and are missing in the oracle.sql pendant, too. Although the guide i have mentions i should use these functions. Perhaps anyone has a working solution for this and could post it here?

I am working with Oracle 9i and Java 1.4 and the 9i intermedia extensions for java on a tomcat.

Attaching the code. I'll try to shorten it as much as possible... Th explicit data format casts result from attempts to use different classes that might work. neither one worked till now.

:: BEGIN CODE :: Connection connection = null;

OracleResultSet resultset = null;
String query = "";
boolean fehler = false;

OrdHttpUploadFormData formdata = new OrdHttpUploadFormData(request); formdata.parseFormData();         

OrdHttpUploadFile pr_steckbrief =
formdata.getFileParameter("pr_steckbrief");         

try {

   Class.forName("oracle.jdbc.driver.OracleDriver");    connection = DriverManager.getConnection(db_url, username, password);    connection.setAutoCommit(false);
   Statement statement = connection.createStatement();                 

   query = "INSERT INTO projekte_data (nummer, titel, beginn, ende, pl, beschreibung, steckbrief) VALUES (" + pr_nummer+ ", " + pr_titel+ ", " + pr_start+ ", " + pr_ende + ", " + pr_projektleiter + ", " + pr_beschreibung + ", ORDSYS.ORDOC.INIT() )";

   statement.executeQuery(query);                         

   query = "SELECT steckbrief FROM projekte_data WHERE nummer = " + pr_nummer + " FOR UPDATE";

   resultset = (OracleResultSet)statement.executeQuery(query);    resultset.next();                         

   OrdDoc media = (OrdDoc)resultset.getCustomDatum(1, OrdDoc.getFactory());    pr_steckbrief.loadBlob(media);
   //formdata.release();                         

   PreparedStatement pstat = (PreparedStatement) connection.prepareStatement("UPDATE projekte_data set steckbrief = ? where nummer = ?");

   pstat.setCustomDatum(1, media);
   pstat.setString(2, pr_nummer);
   pstat.execute();
			

   resultset.close();
   statement.close();
   connection.commit();                 

} catch(ClassNotFoundException e) {

%> Fehler: <%= e %><%

   System.err.println("Error loading driver: " + e); } catch(SQLException e) {

%> Fehler: <%= e %><%

   System.err.println("Error executing SQL-Statement: " + e); } catch(Exception e) {

%> Fehler: <%= e %><%

   System.err.println("Error: Unknown error"); } finally {

   if (connection != null) {
     connection.close();
   }
}

:: END OF CODE :: Thank you very much for your help!
AS Received on Mon Nov 29 2004 - 10:26:43 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US