I have an application that uses PostgreSQL, JSP and the STRUTS Framework
I want to insert a file into a table in PostgreSQL using the OID type, so it’s stored as a large object in the database.
My table definition is this one:
CREATE TABLE mensaje
(
id serial NOT NULL,
file oid,
CONSTRAINT pk_mensaje PRIMARY KEY (id)
)
WITH (
OIDS=TRUE
);
ALTER TABLE mensaje
OWNER TO postgres;
Anybody know an example of how the Action, the ActionForm and the .jsp should be?
If not, is there any other example that explains how to do it without using the OID type?
This is a two step process to solve the problem:
Additional note: Once the file has been received in your Action, you should use the byte array data to save it in your
OIDfield.From your comment, this should be the way in Struts 1.x
In the JSP
In your action class
The
MensajeServiceclass will connect to your Postgre database and save the fileStruts 1 code adapted from: Uploading a file in struts1.
PostreSQL code adapted from here.