You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Claire Wall <cl...@kurtosys.com> on 2003/12/23 15:43:41 UTC

converting a FormFile to a Blob object

hi,

I have a jsp page which uploads a file to a database. I have no problems storing the file in an SQLServer or MySQL database by using the setBinaryStream() method of a PreparedStatement. The file gets upload no problem.

However, when I try to upload this file to an oracle database (BLOB column) it does not work. I'm sure that i have to use the setBlob() method of the PreparedStatement, however, my dilemma is that I cannot find a way to convert my file from FormFile format to sql Blob format. Does anybody know how to do this as I've looked everywhere and haven't come up with a solution.

Any help would be much appreciated 


thanks
claire

Re: converting a FormFile to a Blob object

Posted by Martin Gainty <mg...@hotmail.com>.
if(DriverObject.getName()==org.gjt.mm.mysql.Driver) perform mySQLLogic;
Is this what you're looking for??
Martin
----- Original Message ----- 
From: "Claire Wall" <cl...@kurtosys.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, December 23, 2003 9:43 AM
Subject: converting a FormFile to a Blob object


hi,

I have a jsp page which uploads a file to a database. I have no problems
storing the file in an SQLServer or MySQL database by using the
setBinaryStream() method of a PreparedStatement. The file gets upload no
problem.

However, when I try to upload this file to an oracle database (BLOB column)
it does not work. I'm sure that i have to use the setBlob() method of the
PreparedStatement, however, my dilemma is that I cannot find a way to
convert my file from FormFile format to sql Blob format. Does anybody know
how to do this as I've looked everywhere and haven't come up with a
solution.

Any help would be much appreciated


thanks
claire

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: converting a FormFile to a Blob object

Posted by Marcus Peixoto <mp...@pcltda.com.br>.
Martin, 

Thank you very much. I tried to use JDeveloper some time ago but I gave
up because I didn't find a way to use it with MySql. Now I'll try again.
It's a fantastic tool.

Marcus

Em Ter, 2003-12-23 às 22:20, Martin Gainty escreveu:
> Marcus
> <doc>
> 
> Registering a New Third-Party JDBC Driver
> 
> If you plan to use a third-party JDBC driver, register it with JDeveloper so
> that it will be available when you define the connection.
> 
> To register a new third-party JDBC driver:
> >From the main menu, choose Tools | P references.
> In the Preferences dialog, select Database Connections.
> On the Database Connections page, the Registered JDBC Drivers list displays
> the third-party JDBC drivers currently registered with JDeveloper.
>  To add a new entry to the list, click New.
> A new, entry appears in the list and in the Driver Class field, with a
> default driver class name.
> In the Driver Class field, alter the new entry to reflect its fully
> qualified class name.
> Make sure that the correct entry is still selected in the Registered JDBC
> Drivers list.
> 
> >From the Library dropdown list, select a library to associate the driver
> with.
> To define a new library, click New.
> Be sure to include this library in any project that uses the third-party
> driver.
> Click OK.
> 
> The driver will now appear in the list of available third-party JDBC drivers
> both in this dialog (once you return to it) and in the Create Connection
> wizard
> 
> </doc>
> *Yes as long as the driver is a JDBC Driver which can be/is registered to
> JDeveloper then you can implement that connection from JDeveloper*
> 
> Saludos,
> -Martin
> ----- Original Message ----- 
> From: "Marcus Peixoto" <mp...@pcltda.com.br>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Tuesday, December 23, 2003 1:24 PM
> Subject: Re: converting a FormFile to a Blob object
> 
> 
> > Martin,
> >
> > Does JDeveloper work with any database or just with Oracle ?
> >
> > Marcus
> >
> > Em Ter, 2003-12-23 às 18:53, Martin Gainty escreveu:
> > > 1)you're going to have to download and install JDeveloper
> > > http://otn.oracle.com/software/products/jdev/index.html
> > > The nice thing about JDeveloper is you can create a WebTier/Struts from
> > > File/New
> > >
> > > 2)then read up on the Oracle Blob manipulation
> > > http://otn.oracle.com/sample_code/products/jdev/files/images/sample.html
> > >
> > > Both of these downloads take a while..you might want to try it during
> lunch
> > > assuming you have an unobstructed 100 MB/s connection
> > > Follow the instructions on the 2nd link for downloading, Install, Create
> and
> > > populate DB Tables, creating connection, developing and deploy
> > > This is the only way I know how to capture BLOB and persist to an Oracle
> DB
> > > Get in touch if you need any help..Been there done that!
> > > Good Luck,
> > > -Martin
> > > NB: I had to torque up to 1.5 GB Ram on my box so JDeveloper would run
> in an
> > > expeditious manner..
> > >
> > > ----- Original Message ----- 
> > > From: "Claire Wall" <cl...@kurtosys.com>
> > > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > > Sent: Tuesday, December 23, 2003 9:43 AM
> > > Subject: converting a FormFile to a Blob object
> > >
> > >
> > > hi,
> > >
> > > I have a jsp page which uploads a file to a database. I have no problems
> > > storing the file in an SQLServer or MySQL database by using the
> > > setBinaryStream() method of a PreparedStatement. The file gets upload no
> > > problem.
> > >
> > > However, when I try to upload this file to an oracle database (BLOB
> column)
> > > it does not work. I'm sure that i have to use the setBlob() method of
> the
> > > PreparedStatement, however, my dilemma is that I cannot find a way to
> > > convert my file from FormFile format to sql Blob format. Does anybody
> know
> > > how to do this as I've looked everywhere and haven't come up with a
> > > solution.
> > >
> > > Any help would be much appreciated
> > >
> > >
> > > thanks
> > > claire
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> > -- 
> > Marcus Peixoto <mp...@pcltda.com.br>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
-- 
Marcus Peixoto <mp...@pcltda.com.br>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: converting a FormFile to a Blob object

Posted by Martin Gainty <mg...@hotmail.com>.
Marcus
<doc>

Registering a New Third-Party JDBC Driver

If you plan to use a third-party JDBC driver, register it with JDeveloper so
that it will be available when you define the connection.

To register a new third-party JDBC driver:
>From the main menu, choose Tools | P references.
In the Preferences dialog, select Database Connections.
On the Database Connections page, the Registered JDBC Drivers list displays
the third-party JDBC drivers currently registered with JDeveloper.
 To add a new entry to the list, click New.
A new, entry appears in the list and in the Driver Class field, with a
default driver class name.
In the Driver Class field, alter the new entry to reflect its fully
qualified class name.
Make sure that the correct entry is still selected in the Registered JDBC
Drivers list.

>From the Library dropdown list, select a library to associate the driver
with.
To define a new library, click New.
Be sure to include this library in any project that uses the third-party
driver.
Click OK.

The driver will now appear in the list of available third-party JDBC drivers
both in this dialog (once you return to it) and in the Create Connection
wizard

</doc>
*Yes as long as the driver is a JDBC Driver which can be/is registered to
JDeveloper then you can implement that connection from JDeveloper*

Saludos,
-Martin
----- Original Message ----- 
From: "Marcus Peixoto" <mp...@pcltda.com.br>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, December 23, 2003 1:24 PM
Subject: Re: converting a FormFile to a Blob object


> Martin,
>
> Does JDeveloper work with any database or just with Oracle ?
>
> Marcus
>
> Em Ter, 2003-12-23 às 18:53, Martin Gainty escreveu:
> > 1)you're going to have to download and install JDeveloper
> > http://otn.oracle.com/software/products/jdev/index.html
> > The nice thing about JDeveloper is you can create a WebTier/Struts from
> > File/New
> >
> > 2)then read up on the Oracle Blob manipulation
> > http://otn.oracle.com/sample_code/products/jdev/files/images/sample.html
> >
> > Both of these downloads take a while..you might want to try it during
lunch
> > assuming you have an unobstructed 100 MB/s connection
> > Follow the instructions on the 2nd link for downloading, Install, Create
and
> > populate DB Tables, creating connection, developing and deploy
> > This is the only way I know how to capture BLOB and persist to an Oracle
DB
> > Get in touch if you need any help..Been there done that!
> > Good Luck,
> > -Martin
> > NB: I had to torque up to 1.5 GB Ram on my box so JDeveloper would run
in an
> > expeditious manner..
> >
> > ----- Original Message ----- 
> > From: "Claire Wall" <cl...@kurtosys.com>
> > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Sent: Tuesday, December 23, 2003 9:43 AM
> > Subject: converting a FormFile to a Blob object
> >
> >
> > hi,
> >
> > I have a jsp page which uploads a file to a database. I have no problems
> > storing the file in an SQLServer or MySQL database by using the
> > setBinaryStream() method of a PreparedStatement. The file gets upload no
> > problem.
> >
> > However, when I try to upload this file to an oracle database (BLOB
column)
> > it does not work. I'm sure that i have to use the setBlob() method of
the
> > PreparedStatement, however, my dilemma is that I cannot find a way to
> > convert my file from FormFile format to sql Blob format. Does anybody
know
> > how to do this as I've looked everywhere and haven't come up with a
> > solution.
> >
> > Any help would be much appreciated
> >
> >
> > thanks
> > claire
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> -- 
> Marcus Peixoto <mp...@pcltda.com.br>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: converting a FormFile to a Blob object

Posted by Marcus Peixoto <mp...@pcltda.com.br>.
Martin, 

Does JDeveloper work with any database or just with Oracle ? 

Marcus

Em Ter, 2003-12-23 às 18:53, Martin Gainty escreveu:
> 1)you're going to have to download and install JDeveloper
> http://otn.oracle.com/software/products/jdev/index.html
> The nice thing about JDeveloper is you can create a WebTier/Struts from
> File/New
> 
> 2)then read up on the Oracle Blob manipulation
> http://otn.oracle.com/sample_code/products/jdev/files/images/sample.html
> 
> Both of these downloads take a while..you might want to try it during lunch
> assuming you have an unobstructed 100 MB/s connection
> Follow the instructions on the 2nd link for downloading, Install, Create and
> populate DB Tables, creating connection, developing and deploy
> This is the only way I know how to capture BLOB and persist to an Oracle DB
> Get in touch if you need any help..Been there done that!
> Good Luck,
> -Martin
> NB: I had to torque up to 1.5 GB Ram on my box so JDeveloper would run in an
> expeditious manner..
> 
> ----- Original Message ----- 
> From: "Claire Wall" <cl...@kurtosys.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Tuesday, December 23, 2003 9:43 AM
> Subject: converting a FormFile to a Blob object
> 
> 
> hi,
> 
> I have a jsp page which uploads a file to a database. I have no problems
> storing the file in an SQLServer or MySQL database by using the
> setBinaryStream() method of a PreparedStatement. The file gets upload no
> problem.
> 
> However, when I try to upload this file to an oracle database (BLOB column)
> it does not work. I'm sure that i have to use the setBlob() method of the
> PreparedStatement, however, my dilemma is that I cannot find a way to
> convert my file from FormFile format to sql Blob format. Does anybody know
> how to do this as I've looked everywhere and haven't come up with a
> solution.
> 
> Any help would be much appreciated
> 
> 
> thanks
> claire
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
-- 
Marcus Peixoto <mp...@pcltda.com.br>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: converting a FormFile to a Blob object

Posted by Martin Gainty <mg...@hotmail.com>.
1)you're going to have to download and install JDeveloper
http://otn.oracle.com/software/products/jdev/index.html
The nice thing about JDeveloper is you can create a WebTier/Struts from
File/New

2)then read up on the Oracle Blob manipulation
http://otn.oracle.com/sample_code/products/jdev/files/images/sample.html

Both of these downloads take a while..you might want to try it during lunch
assuming you have an unobstructed 100 MB/s connection
Follow the instructions on the 2nd link for downloading, Install, Create and
populate DB Tables, creating connection, developing and deploy
This is the only way I know how to capture BLOB and persist to an Oracle DB
Get in touch if you need any help..Been there done that!
Good Luck,
-Martin
NB: I had to torque up to 1.5 GB Ram on my box so JDeveloper would run in an
expeditious manner..

----- Original Message ----- 
From: "Claire Wall" <cl...@kurtosys.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, December 23, 2003 9:43 AM
Subject: converting a FormFile to a Blob object


hi,

I have a jsp page which uploads a file to a database. I have no problems
storing the file in an SQLServer or MySQL database by using the
setBinaryStream() method of a PreparedStatement. The file gets upload no
problem.

However, when I try to upload this file to an oracle database (BLOB column)
it does not work. I'm sure that i have to use the setBlob() method of the
PreparedStatement, however, my dilemma is that I cannot find a way to
convert my file from FormFile format to sql Blob format. Does anybody know
how to do this as I've looked everywhere and haven't come up with a
solution.

Any help would be much appreciated


thanks
claire

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: converting a FormFile to a Blob object

Posted by Christian Bollmeyer <ja...@christianbollmeyer.de>.
Am Dienstag, 23. Dezember 2003 15:43 schrieb Claire Wall:
> hi,

Oracle is different from other databases when it comes to LOBs
due to the LOB locator concept. IIRC you have to use the Oracle JDBC 
extensions for that (oracle.jdbc.*). Some links that may be helpful:

http://www.csee.umbc.edu/help/oracle8/java.815/a64685/
oraext4.htm#1043351
http://www.csee.umbc.edu/help/oracle8/java.815/a64685/samapp2.htm

Then, getting an InputStream from the FormFile and writing the
contents to the database via blob.getBinaryOutputStream() is
just routine. That's how we do it, at least, and it works perfectly
with the thin driver, too.

HTH,
-- Chris 

> I have a jsp page which uploads a file to a database. I have no
> problems storing the file in an SQLServer or MySQL database by using
> the setBinaryStream() method of a PreparedStatement. The file gets
> upload no problem.
>
> However, when I try to upload this file to an oracle database (BLOB
> column) it does not work. I'm sure that i have to use the setBlob()
> method of the PreparedStatement, however, my dilemma is that I cannot
> find a way to convert my file from FormFile format to sql Blob
> format. Does anybody know how to do this as I've looked everywhere
> and haven't come up with a solution.
>
> Any help would be much appreciated
>
>
> thanks
> claire


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org