pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedlargeobjects deadlock ?
2+ messages / 1 participants
[nested] [flat]
* largeobjects deadlock ?
@ 2005-10-25 23:49 andy petrella <andy.petrella@gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: andy petrella @ 2005-10-25 23:49 UTC (permalink / raw)
To: pgsql-jdbc
HI all,
I have somme problem with largeobjects setting in a preparedstatement, here
is the code with the problem in comment // :
[...]
db.setAutoCommit(false);
[...]
LargeObjectManager lobj = pgdb.getLargeObjectAPI(); //pgdb is a
PGConnection
int loid = lobj.create();
System.out.println("loid : " + loid); //this give 359648
LargeObject image = lobj.open(loid);
int s, count = 0;
byte buf[] = new byte[2048];
while ((s = affiche.read(buf, 0, buf.length)) > 0){ //affiche is an
InputStream
count += s;
image.write(buf, 0, s);
}
BlobInputStream b = new BlobInputStream(image);
addDVD.setBinaryStream(4, b, count); //addDVD is an PreparedStatement
//addDVD.setNull(4, java.sql.Types.BINARY); // --> all work well if I
decomment this and comment the preceding
image.close();
affiche.close();
[...]
System.out.println("addDVD : " + addDVD.toString()); //<stream of 6503
bytes> for the fourth prm (bytea)
int update = addDVD.executeUpdate(); // -->deadlocking here !!!
System.out.println("update = " + update); //never pass here
db.setAutoCommit(true);
[...]
Am I setting the bytea in the rigth manner ? Else, how may I do that , where
are my mistakes ?
Thx u all.
andy
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: largeobjects deadlock ?
@ 2005-10-26 00:42 andy petrella <andy.petrella@gmail.com>
parent: andy petrella <andy.petrella@gmail.com>
0 siblings, 0 replies; 2+ messages in thread
From: andy petrella @ 2005-10-26 00:42 UTC (permalink / raw)
To: pgsql-jdbc
Oh, finally it seems rigth but my problem comes with the insertion in a
function written in plpgsql... so how may I do to insert a bytea receive
with an ROW ?
CREATE OR REPLACE FUNCTION
rule_dvd (FICHES.DVD)
RETURNS INT
AS $Func$
DECLARE
fiche_dvd ALIAS FOR $1;
[...]
INSERT INTO INFORMATIONS.FILMS
(
id,
titre_o,
titre_f,
sortie,
affiche,
duree,
genre,
resume,
visites,
cote,
imdb
)
VALUES
(
default,
fiche_dvd.titre_o,
fiche_dvd.titre_f,
fiche_dvd.sortie,
fiche_dvd.affiche, //??????????????
fiche_dvd.duree,
fiche_dvd.genre,
fiche_dvd.resume,
1,
0,
fiche_dvd.imdb
);
[...]
I think that's my problem... but how can I do else ?
Thx (and apologize my english...)
andy
2005/10/26, andy petrella <andy.petrella@gmail.com>:
>
> HI all,
>
> I have somme problem with largeobjects setting in a preparedstatement,
> here is the code with the problem in comment // :
>
> [...]
> db.setAutoCommit(false);
> [...]
> LargeObjectManager lobj = pgdb.getLargeObjectAPI(); //pgdb is a
> PGConnection
> int loid = lobj.create();
> System.out.println("loid : " + loid); //this give 359648
> LargeObject image = lobj.open(loid);
> int s, count = 0;
> byte buf[] = new byte[2048];
> while ((s = affiche.read(buf, 0, buf.length)) > 0){ //affiche is an
> InputStream
> count += s;
> image.write(buf, 0, s);
> }
> BlobInputStream b = new BlobInputStream(image);
> addDVD.setBinaryStream(4, b, count); //addDVD is an PreparedStatement
> //addDVD.setNull(4, java.sql.Types.BINARY); // --> all work well if I
> decomment this and comment the preceding
> image.close();
> affiche.close();
> [...]
> System.out.println("addDVD : " + addDVD.toString()); // <stream of 6503
> bytes> for the fourth prm (bytea)
>
> int update = addDVD.executeUpdate(); // -->deadlocking here !!!
> System.out.println("update = " + update); //never pass here
> db.setAutoCommit(true);
> [...]
>
> Am I setting the bytea in the rigth manner ? Else, how may I do that ,
> where are my mistakes ?
>
> Thx u all.
>
> andy
>
>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2005-10-26 00:42 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-10-25 23:49 largeobjects deadlock ? andy petrella <andy.petrella@gmail.com>
2005-10-26 00:42 ` andy petrella <andy.petrella@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox