Thread: insufficient data left in message II
> From: oliver@opencloud.com
> To: seppwimmer@hotmail.com
> CC: pgsql-jdbc@postgresql.org
> Subject: Re: [JDBC] ERROR: insufficient data left in message
>
> Robert Wimmer wrote:
> > I always get the error 'insufficient data left in message' running a
> > prepared statement via jdbc executeQuery
>
ican locate the problem better now. the prepared insert statement is NOTthe origin cause. if the following lines are commented out no errorwill occur only SOMETIMES and the insert and the update statement willwork as expected.
***
// should not be found
//if (proxy.get(person,new Long(45678)))
// System.out.println('found : ' + person.toString()); <<<< here is the problem
// else System.out.println('not found : ' + person.toString());
**** and now the rest works fine
// update
person.setFirstName('Homero');
if (proxy.update(person)) System.out.println('updated : ' + person.toString());
else System.out.println('not updated : ' + person.toString());
// insert a new one
Person person2 = new Person();
person2.setFirstName('Ropert');
person2.setLastName('Wimmer');
person2.setReadOnly(false);
person2.setBirthDay(null);
if (proxy.insert(person2)) System.out.println('inserted : ' + person2.toString());
else System.out.println('inserted : ' + person2.toString());
}
**** output
updated : [1] Simpson, Homero (readOnly=false, private=)
inserted : [null] Wimmer, Ropert (readOnly=false, private=)
done
****
thestrange thing is if I run the program above from the command line theresult depends on what happend during the last call of the program. soif i change the program in the IDE in a way that an error will occurthe sam error will also occur from the commandline for the next 2 or 3times - afterwards it will work as expected.
my suspicion is, that if the get statement returns nothing this error will occur.
***
ResultSet rs = this.getStatement.executeQuery();
if (rs.first()) { readResultSet(rs,data); ret = true; }
rs.close();
// getStatement = 'SELECT * FROM person.person WHERE id = ?'
***
butthe error only will occur if I run an insert or update statementafterwards. I.E. if i only do not find no error will occur but if iupdate or insert afterwards this error will occur ! and vice versa - aslong as there is no NOT FOUND the insert & update statement willwork.
if a reproduce this situation (not finding data) i get the following log entries
***
2008-04-29 12:14:54 CEST LOG: unexpected EOF on client connection
2008-04-29 12:14:58 CEST LOG: could not receive data from client: Connection reset by peer
2008-04-29 12:14:58 CEST LOG: unexpected EOF on client connection
2008-04-29 12:15:01 CEST LOG: could not receive data from client: Connection reset by peer
2008-04-29 12:15:01 CEST LOG: unexpected EOF on client connection
2008-04-29 12:15:06 CEST LOG: could not receive data from client: Connection reset by peer
2008-04-29 12:15:06 CEST LOG: unexpected EOF on client connection
2008-04-29 12:15:13 CEST LOG: could not receive data from client: Connection reset by peer
2008-04-29 12:15:13 CEST LOG: unexpected EOF on client connection
2008-04-29 12:15:22 CEST LOG: could not receive data from client: Connection reset by peer
2008-04-29 12:15:22 CEST LOG: unexpected EOF on client connection
***
the 'unexpected EOF ...' is very suspicous to me.
any ideas ?
regards sepp
Es ist höchste Zeit, dabei zu sein - Holen Sie sich jetzt die neue Generation der Windows Live Services! Hier klicken!
Robert Wimmer wrote: > ican locate the problem better now. the prepared insert statement is > NOTthe origin cause. if the following lines are commented out no > errorwill occur only SOMETIMES and the insert and the update statement > willwork as expected. What OS are you using (client & server)? If you're running Windows, do you have any firewall / antivirus software installed? Does the problem go away if you disable it? Can you get a network capture of a case when it fails? (e.g. with tcpdump or wireshark) -O
>
> What OS are you using (client & server)?
>
linux on the server, win-xp on the client
> If you're running Windows, do you have any firewall / antivirus software
> installed? Does the problem go away if you disable it?
>
no firewall and no antivirus software
> Can you get a network capture of a case when it fails? (e.g. with
> tcpdump or wireshark)
>
never done this before ...
but that is (was) not the problem. i tried to isolate the
problem and wrote a short program running more or less the same statements but in
a direct way. and now i got NO ERRORS at all. so i think the problem could be setting
the parameters via reflection or something like that.
so i think i have to start from the beginning ...
thanx for helping
Wann haben Sie das letzte Mal Ihre Freunde oder Familie gesehen? Unlimitierte Videotelefonate mit dem Windows Live Messenger. Hier klicken!
> What OS are you using (client & server)?
>
linux on the server, win-xp on the client
> If you're running Windows, do you have any firewall / antivirus software
> installed? Does the problem go away if you disable it?
>
no firewall and no antivirus software
> Can you get a network capture of a case when it fails? (e.g. with
> tcpdump or wireshark)
>
never done this before ...
but that is (was) not the problem. i tried to isolate the
problem and wrote a short program running more or less the same statements but in
a direct way. and now i got NO ERRORS at all. so i think the problem could be setting
the parameters via reflection or something like that.
so i think i have to start from the beginning ...
thanx for helping
Wann haben Sie das letzte Mal Ihre Freunde oder Familie gesehen? Unlimitierte Videotelefonate mit dem Windows Live Messenger. Hier klicken!
now i am able to reproduce this error.
the error occurs if you set a (nullable) parameter in a prepared statement to null the "wrong way".
here are 4 examples and what happens
***
PreparedStatement stmt ...;
stmt.setObject(3,new Date(1000)); // no error
stmt.setObject(3,(java.sql.Date)null); // no error
stmt.setDate(3,(java.sql.Date)null); // -> ERROR: insufficient data left in message
stmt.setNull(3,java.sql.Types.DATE); // -> ERROR: insufficient data left in message
***
really surprising to me is that it seems impossible to set NULL values via "setDate" and even more
surprising is that "setNull(...)" using the correct datatype does not work. i dont think that this is the
expected behavior and the error message is misleading too.
another interesteing behaviour is that, if you get this error you will also get this error running
the correct statement. but after calling the correct statement a few times the error message will disappear.
regards sepp
Wann haben Sie das letzte Mal Ihre Freunde oder Familie gesehen? Unlimitierte Videotelefonate mit dem Windows Live Messenger. Hier klicken!
Wann haben Sie das letzte Mal Ihre Freunde oder Familie gesehen? Unlimitierte Videotelefonate mit dem Windows Live Messenger. Hier klicken!
Robert Wimmer wrote: > now i am able to reproduce this error. > > the error occurs if you set a (nullable) parameter in a prepared > statement to null the "wrong way". > here are 4 examples and what happens > > *** > PreparedStatement stmt ...; What is the query you are using and against what schema? If you can send us a compilable program that shows just the problem that would be perfect. -O
> Robert Wimmer wrote:
> > now i am able to reproduce this error.
> >
> > the error occurs if you set a (nullable) parameter in a prepared
> > statement to null the "wrong way".
> > here are 4 examples and what happens
> >
> > ***
> > PreparedStatement stmt ...;
>
> What is the query you are using and against what schema?
>
> If you can send us a compilable program that shows just the problem that
> would be perfect.
>
the problem only occurs only in a specific complex context (an eclipse plugin i wrote).
if I amrunning equal prepared statements on the same database and table with equivalent
parameters in an other (more simple environment) this error wont happen.
so i will try to reproduce this error in a more simple environment.
i dont want to bother you with this plugin.
so, at the moment, i am not sure that this is a pg-jdbc problem. may be it is
only a misleading error message.
but i will post the result here any way
regards sepp
Hohe Telefonrechnungen? Gratis Gespräche von PC zu PC - unlimitiert mit dem Windows Live Messenger. Hier klicken!
> > now i am able to reproduce this error.
> >
> > the error occurs if you set a (nullable) parameter in a prepared
> > statement to null the "wrong way".
> > here are 4 examples and what happens
> >
> > ***
> > PreparedStatement stmt ...;
>
> What is the query you are using and against what schema?
>
> If you can send us a compilable program that shows just the problem that
> would be perfect.
>
the problem only occurs only in a specific complex context (an eclipse plugin i wrote).
if I amrunning equal prepared statements on the same database and table with equivalent
parameters in an other (more simple environment) this error wont happen.
so i will try to reproduce this error in a more simple environment.
i dont want to bother you with this plugin.
so, at the moment, i am not sure that this is a pg-jdbc problem. may be it is
only a misleading error message.
but i will post the result here any way
regards sepp
Hohe Telefonrechnungen? Gratis Gespräche von PC zu PC - unlimitiert mit dem Windows Live Messenger. Hier klicken!