Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> JSP & Oracle InterMedia
Hi NG,
I have got a (big?) problem with Oracle Intermedia. What i want to do is:
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
![]() |
![]() |