You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@beehive.apache.org by sourmugster <so...@gmail.com> on 2007/11/13 19:28:05 UTC

Jdbc Control - Blob insert

Hi,

I'm trying to insert a blob in an Oracle database using a JDBCControl. What
is the best way to accomplish this. Assume I have the following
definition...

public static class Foo{
    public String id;
    public Blob xml;
}
@SQL(statement="INSERT INTO Foo (id, xml) VALUES ({id} ,{xml})
public int addUser(String id, Blob xml ) throws SQLException;

I've created an implementation class that calls the addUser() method in the
JDBC Control.  

Do I have to use Oracle's empty_blob() function to insert an empty blob
before inserting the actual xml. If so, how can this be done? Or are there
other possibilities f.i. use a byte[] as type instead of the sql.Blob 

All tips, tricks, samples are welcome...
Thx in advance.





-- 
View this message in context: http://www.nabble.com/Jdbc-Control---Blob-insert-tf4799688.html#a13731772
Sent from the Beehive - User mailing list archive at Nabble.com.


Re: Jdbc Control - Blob insert

Posted by Giovanni Motta <mo...@gmail.com>.
I have done something similar using a byte[] instead of Blob. It works for
me, your sample code should become:

public static class Foo{
   public String id;
   public byte[] xml;
} @SQL(statement="INSERT INTO Foo (id, xml) VALUES ({id} ,{xml})
public int addUser(String id, byte[] xml ) throws SQLException;

Regards.
Giovanni


2007/11/13, sourmugster <so...@gmail.com>:
>
>
> Hi,
>
> I'm trying to insert a blob in an Oracle database using a JDBCControl.
> What
> is the best way to accomplish this. Assume I have the following
> definition...
>
> public static class Foo{
>    public String id;
>    public Blob xml;
> }
> @SQL(statement="INSERT INTO Foo (id, xml) VALUES ({id} ,{xml})
> public int addUser(String id, Blob xml ) throws SQLException;
>
> I've created an implementation class that calls the addUser() method in
> the
> JDBC Control.
>
> Do I have to use Oracle's empty_blob() function to insert an empty blob
> before inserting the actual xml. If so, how can this be done? Or are there
> other possibilities f.i. use a byte[] as type instead of the sql.Blob
>
> All tips, tricks, samples are welcome...
> Thx in advance.
>
>
>
>
>
> --
> View this message in context:
> http://www.nabble.com/Jdbc-Control---Blob-insert-tf4799688.html#a13731772
> Sent from the Beehive - User mailing list archive at Nabble.com.
>
>