pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feednext() error
3+ messages / 2 participants
[nested] [flat]
* next() error
@ 2005-02-03 22:51 Nahum Castro <nahumcastro@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Nahum Castro @ 2005-02-03 22:51 UTC (permalink / raw)
To: pgsql-jdbc
I am using postgresql 8 and the 8 JDBC 3 driver.
I get the next error:
javax.servlet.ServletException: ResultSet not positioned properly,
perhaps you need to call next.
This code used to work on postgresql 7.4.6 and 215 JDBC 3 driver
Has changed something on the server or on the driver?
Thanks for your help.
This is the code on a jsp page:
-------------------------------------------------------------------------------------
<%@ page contentType="text/html; charset=iso-8859-1" language="java"
import="java.sql.*" errorPage="" %>
<%@ include file="Connections/connPubs.jsp" %>
<%
String RecordsetPubs1 = "1";
if (request.getParameter("au_id") != null)
{
RecordsetPubs1 = (String)request.getParameter("au_id");
}
%>
<%
Driver DriverRecordsetPubs1 =
(Driver)Class.forName(connPubs_DRIVER).newInstance();
Connection ConnRecordsetPubs1 =
DriverManager.getConnection(connPubs_STRING,connPubs_USERNAME,connPubs_PASSWORD);
PreparedStatement StatementRecordsetPubs1 =
ConnRecordsetPubs1.prepareStatement("SELECT * FROM public.authors
WHERE au_id = " + RecordsetPubs1 + "");
ResultSet RecordsetPubs1 = StatementRecordsetPubs1.executeQuery();
boolean RecordsetPubs1_isEmpty = ! RecordsetPubs1.next();
boolean RecordsetPubs1_hasData = ! RecordsetPubs1_isEmpty;
Object RecordsetPubs1_data;
int RecordsetPubs1_numRows = 0;
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd";
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table align="center" border="1">
<tr>
<td align="left" width="50%">au_id</td>
<td align="left" width="50%"><%=(((RecordsetPubs1_data =
RecordsetPubs1.getObject("au_id"))==null ||
RecordsetPubs1.wasNull())?"":RecordsetPubs1_data)%></td>
</tr>
<tr>
<td align="left" width="50%">au_lname</td>
<td align="left" width="50%"><%=(((RecordsetPubs1_data =
RecordsetPubs1.getObject("au_lname"))==null ||
RecordsetPubs1.wasNull())?"":RecordsetPubs1_data)%></td>
</tr>
<tr>
<td align="left" width="50%">au_fname</td>
<td align="left" width="50%"><%=(((RecordsetPubs1_data =
RecordsetPubs1.getObject("au_fname"))==null ||
RecordsetPubs1.wasNull())?"":RecordsetPubs1_data)%></td>
</tr>
<tr>
<td align="left" width="50%">phone</td>
<td align="left" width="50%"><%=(((RecordsetPubs1_data =
RecordsetPubs1.getObject("phone"))==null ||
RecordsetPubs1.wasNull())?"":RecordsetPubs1_data)%></td>
</tr>
<tr>
<td align="left" width="50%">address</td>
<td align="left" width="50%"><%=(((RecordsetPubs1_data =
RecordsetPubs1.getObject("address"))==null ||
RecordsetPubs1.wasNull())?"":RecordsetPubs1_data)%></td>
</tr>
<tr>
<td align="left" width="50%">city</td>
<td align="left" width="50%"><%=(((RecordsetPubs1_data =
RecordsetPubs1.getObject("city"))==null ||
RecordsetPubs1.wasNull())?"":RecordsetPubs1_data)%></td>
</tr>
<tr>
<td align="left" width="50%">state</td>
<td align="left" width="50%"><%=(((RecordsetPubs1_data =
RecordsetPubs1.getObject("state"))==null ||
RecordsetPubs1.wasNull())?"":RecordsetPubs1_data)%></td>
</tr>
<tr>
<td align="left" width="50%">zip</td>
<td align="left" width="50%"><%=(((RecordsetPubs1_data =
RecordsetPubs1.getObject("zip"))==null ||
RecordsetPubs1.wasNull())?"":RecordsetPubs1_data)%></td>
</tr>
</table>
</body>
</html>
<%
RecordsetPubs1.close();
StatementRecordsetPubs1.close();
ConnRecordsetPubs1.close();
%>
--------------------------------------------------------------------------------------
--
Nahum Castro González
León, Guanajuato, México
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: next() error
@ 2005-02-03 23:05 Oliver Jowett <oliver@opencloud.com>
parent: Nahum Castro <nahumcastro@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Oliver Jowett @ 2005-02-03 23:05 UTC (permalink / raw)
To: Nahum Castro <nahumcastro@gmail.com>; +Cc: pgsql-jdbc
Nahum Castro wrote:
> javax.servlet.ServletException: ResultSet not positioned properly,
> perhaps you need to call next.
> Has changed something on the server or on the driver?
Newer drivers follow the JDBC specification more strictly.
> ResultSet RecordsetPubs1 = StatementRecordsetPubs1.executeQuery();
> boolean RecordsetPubs1_isEmpty = ! RecordsetPubs1.next();
> boolean RecordsetPubs1_hasData = ! RecordsetPubs1_isEmpty;
[...]
> <td align="left" width="50%"><%=(((RecordsetPubs1_data =
> RecordsetPubs1.getObject("au_id"))==null ||
> RecordsetPubs1.wasNull())?"":RecordsetPubs1_data)%></td>
You appear to be calling ResultSet.getObject() even if ResultSet.next()
returned false. You're not allowed to do this -- see the JDBC javadoc.
-O
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: next() error
@ 2005-02-04 00:35 Nahum Castro <nahumcastro@gmail.com>
parent: Oliver Jowett <oliver@opencloud.com>
0 siblings, 0 replies; 3+ messages in thread
From: Nahum Castro @ 2005-02-04 00:35 UTC (permalink / raw)
To: pgsql-jdbc
On Fri, 04 Feb 2005 12:05:12 +1300, Oliver Jowett <oliver@opencloud.com> wrote:
> Nahum Castro wrote:
>
> > javax.servlet.ServletException: ResultSet not positioned properly,
> > perhaps you need to call next.
>
> > Has changed something on the server or on the driver?
>
> Newer drivers follow the JDBC specification more strictly.
>
> > ResultSet RecordsetPubs1 = StatementRecordsetPubs1.executeQuery();
> > boolean RecordsetPubs1_isEmpty = ! RecordsetPubs1.next();
> > boolean RecordsetPubs1_hasData = ! RecordsetPubs1_isEmpty;
>
> [...]
>
> > <td align="left" width="50%"><%=(((RecordsetPubs1_data =
> > RecordsetPubs1.getObject("au_id"))==null ||
> > RecordsetPubs1.wasNull())?"":RecordsetPubs1_data)%></td>
>
> You appear to be calling ResultSet.getObject() even if ResultSet.next()
> returned false. You're not allowed to do this -- see the JDBC javadoc.
>
> -O
>
Thank you.
I solved the problem now.
--
Nahum Castro González
León, Guanajuato, México
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2005-02-04 00:35 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-02-03 22:51 next() error Nahum Castro <nahumcastro@gmail.com>
2005-02-03 23:05 ` Oliver Jowett <oliver@opencloud.com>
2005-02-04 00:35 ` Nahum Castro <nahumcastro@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