pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedexecuteQuery returns postgresql.stat.result
5+ messages / 2 participants
[nested] [flat]
* executeQuery returns postgresql.stat.result
@ 2005-05-01 17:24 Nico <nicohmail-postgresql@yahoo.com>
0 siblings, 1 reply; 5+ messages in thread
From: Nico @ 2005-05-01 17:24 UTC (permalink / raw)
To: pgsql-jdbc
Hi,
When I try
try
{
sql="select * from \"qryMonthsYears\"";
java.sql.ResultSet
resultset=getQuery(sql,connection.createStatement());
}
catch(java.sql.SQLException fout)
{
java.sql.SQLException foutje=fout.getNextException();
out.println("<br>SQL fout: "+fout.getMessage());
while(foutje!=null)
{
out.print("<br>Ingebedde fout: "+foutje.getMessage());
foutje=fout.getNextException();
}
}
I get the following exception when I try this:
Batch entry 0 select * from "qryMonthsYears"; was aborted. Call
getNextException() to see the cause.
When I call getNextException(), I get the following result:
postgresql.stat.result
and stays in the loop.
Here is the code for the method getQuery:
ResultSet resultset;
if(strstatement.startsWith("SELECT"))
{
resultset=statement.executeQuery(strstatement);
if(resultset==null)
throw new SQLException("Resultset is null at getQuery().");
if(resultset.getWarnings()==null)
return resultset;
else
{
String errmessage="";
while(resultset.getWarnings().getErrorCode()!=0)
{
errmessage+=resultset.getWarnings().getMessage()+"\n";
resultset.getWarnings().getNextException();
}
throw new SQLException("SQL Fout getQuery(): "+errmessage);
}
}
else
{
connection.setAutoCommit(false);
String [] sql=strstatement.split(";");
for(int teller=0;teller<sql.length;teller++)
statement.addBatch(sql[teller]+";");
statement.executeBatch();
connection.commit();
connection.setAutoCommit(true);
return null;
}
Please help!
Nico.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: executeQuery returns postgresql.stat.result
@ 2005-05-01 17:32 Kris Jurka <books@ejurka.com>
parent: Nico <nicohmail-postgresql@yahoo.com>
0 siblings, 1 reply; 5+ messages in thread
From: Kris Jurka @ 2005-05-01 17:32 UTC (permalink / raw)
To: Nico <nicohmail-postgresql@yahoo.com>; +Cc: pgsql-jdbc
On Sun, 1 May 2005, Nico wrote:
> sql="select * from \"qryMonthsYears\"";
>...
> if(strstatement.startsWith("SELECT"))
>...
> else
> {
> connection.setAutoCommit(false);
> String [] sql=strstatement.split(";");
> for(int teller=0;teller<sql.length;teller++)
> statement.addBatch(sql[teller]+";");
> statement.executeBatch();
Your own parsing logic is busted and is trying to execute a select in a
batch statement, which is not legal.
Kris Jurka
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: executeQuery returns postgresql.stat.result
@ 2005-05-01 17:59 Nico <nicohmail-postgresql@yahoo.com>
parent: Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 5+ messages in thread
From: Nico @ 2005-05-01 17:59 UTC (permalink / raw)
To: pgsql-jdbc
The batch statement is ONLY used in case of an update, insert or delete
command.
When a select command is used, there is no batch used, as you can see in my
code.
Nico.
"Kris Jurka" <books@ejurka.com> schreef in bericht
news:Pine.BSO.4.56.0505011230450.1107@leary.csoft.net...
>
>
> On Sun, 1 May 2005, Nico wrote:
>
>> sql="select * from \"qryMonthsYears\"";
>>...
>> if(strstatement.startsWith("SELECT"))
>>...
>> else
>> {
>> connection.setAutoCommit(false);
>> String [] sql=strstatement.split(";");
>> for(int teller=0;teller<sql.length;teller++)
>> statement.addBatch(sql[teller]+";");
>> statement.executeBatch();
>
> Your own parsing logic is busted and is trying to execute a select in a
> batch statement, which is not legal.
>
> Kris Jurka
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: executeQuery returns postgresql.stat.result
@ 2005-05-01 18:04 Kris Jurka <books@ejurka.com>
parent: Nico <nicohmail-postgresql@yahoo.com>
0 siblings, 1 reply; 5+ messages in thread
From: Kris Jurka @ 2005-05-01 18:04 UTC (permalink / raw)
To: Nico <nicohmail-postgresql@yahoo.com>; +Cc: pgsql-jdbc
On Sun, 1 May 2005, Nico wrote:
> The batch statement is ONLY used in case of an update, insert or delete
> command. When a select command is used, there is no batch used, as you
> can see in my code.
No, I can't see that. You have a case mismatch between your sql and your
test. A simple examination of the stacktrace from this error would
clearly show the wrong code being called.
Kris Jurka
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: executeQuery returns postgresql.stat.result
@ 2005-05-01 19:00 Nico <nicohmail-postgresql@yahoo.com>
parent: Kris Jurka <books@ejurka.com>
0 siblings, 0 replies; 5+ messages in thread
From: Nico @ 2005-05-01 19:00 UTC (permalink / raw)
To: pgsql-jdbc
I noticed it. Because the exception was captured, it didn't show a
stacktrace.
I solved it and it works fine now. Thanks.
Nico.
"Kris Jurka" <books@ejurka.com> schreef in bericht
news:Pine.BSO.4.56.0505011302210.22827@leary.csoft.net...
>
>
> On Sun, 1 May 2005, Nico wrote:
>
>> The batch statement is ONLY used in case of an update, insert or delete
>> command. When a select command is used, there is no batch used, as you
>> can see in my code.
>
> No, I can't see that. You have a case mismatch between your sql and your
> test. A simple examination of the stacktrace from this error would
> clearly show the wrong code being called.
>
> Kris Jurka
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2005-05-01 19:00 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-05-01 17:24 executeQuery returns postgresql.stat.result Nico <nicohmail-postgresql@yahoo.com>
2005-05-01 17:32 ` Kris Jurka <books@ejurka.com>
2005-05-01 17:59 ` Nico <nicohmail-postgresql@yahoo.com>
2005-05-01 18:04 ` Kris Jurka <books@ejurka.com>
2005-05-01 19:00 ` Nico <nicohmail-postgresql@yahoo.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