Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 4FFB69F9D57 for ; Thu, 27 Sep 2007 07:27:01 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 04377-04 for ; Thu, 27 Sep 2007 07:26:48 -0300 (ADT) X-Greylist: delayed 00:06:40.339028 by SQLgrey-1.7.5 Received: from web31903.mail.mud.yahoo.com (web31903.mail.mud.yahoo.com [68.142.207.83]) by postgresql.org (Postfix) with SMTP id 3F56C9F9B2D for ; Thu, 27 Sep 2007 07:26:52 -0300 (ADT) Received: (qmail 89592 invoked by uid 60001); 27 Sep 2007 10:20:10 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.it; h=X-YMail-OSG:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=aY/C32hjW3IAIBrMHhTYSR8VCjSS91Fk0HBCv3JYj2KvoauGiO2Q+eIo8MUZX5nOahRNRal87mt6a5MlnNO8cWnn2wmBLGQAdc6K4Xuj5x96pxf6JrFboG2haWKOrw18sB4EquknaOYm+hBew8w/qjJ0gF8A6oBVrIIuz1ifwNc=; X-YMail-OSG: tAz90VkVM1kPh5ozyxL.itHkt4mGo8Ou.t99._P9u14wGMaPE1j38uOFMxOHAJLL4fLB31PMoWNub_SqLvgavyTVyR8Xp3N.p86mVBmWKvlqnn9eguv_OJUyr7dE_Q-- Received: from [87.5.225.71] by web31903.mail.mud.yahoo.com via HTTP; Thu, 27 Sep 2007 12:20:10 CEST Date: Thu, 27 Sep 2007 12:20:10 +0200 (CEST) From: Ludovico Bianchini Subject: ResultSet with more than 5 rows causes error To: pgsql-jdbc@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <520533.88896.qm@web31903.mail.mud.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/119 X-Sequence-Number: 17541 I'm using jdbc4 driver with postgresql 8.1, java sdk 6 and netbeans 5.5 The task to perform is to copy rows from one table to another (tables with same structure) in a distinct database, using stored procedure. This code works fine when the ResultSet has max 5 rows. If it has 6 rows, when calling getObject(int index) an error occurs. The error seems to be PSQLException, telling that the ResultSet is bad positioned and an hit could be calling next(). But it's not clear: what I have caught is a NullPointerException public void upload(Connection localConnection, Connection remoteConnection) throws SQLException{ ResultSet source; ResultSetMetaData md; SQLWarning warning; Object data; int colCount; try { if (localConnection != null && remoteConnection != null && !localConnection.isClosed() && !remoteConnection.isClosed()) { remoteConnection.setAutoCommit(false); CallableStatement selectCall = localConnection.prepareCall(Constant.FUNCTION_SELECT); CallableStatement insertCall = remoteConnection.prepareCall(Constant.FUNCTION_INSERT); source = selectCall.executeQuery(); md = source.getMetaData(); colCount = md.getColumnCount(); while(source.next()) { insertCall.registerOutParameter(1, Types.INTEGER); for (int i = 1; i <= colCount; i++) { data = source.getObject(i); insertCall.setObject(i+1, data); } insertCall.execute(); warning = insertCall.getWarnings(); insertCall.clearParameters(); } source.close(); selectCall.close(); insertCall.close(); remoteConnection.commit(); remoteConnection.close(); } } catch (PSQLException ex) { remoteConnection.rollback(); remoteConnection.close(); } catch (SQLException ex) { remoteConnection.rollback(); remoteConnection.close(); } catch (Exception ex) { remoteConnection.rollback(); remoteConnection.close(); } } Abybody can help me to find an answer? Thanks in advance ___________________________________ L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail: http://it.docs.yahoo.com/nowyoucan.html