pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Anil Amarakoon <anil@server.awcoldstream.com>
To: Felix Morley Finch <felix@crowfix.com>
Cc: pgsql-interfaces@postgreSQL.org <pgsql-interfaces@postgreSQL.org>
Subject: Re: [INTERFACES] jdbc can't getResult of "select nextval (seq_name)"
Date: Fri, 08 May 1998 23:57:06 -0500
Message-ID: <3553E222.1DFF7079@awcoldstream.com> (raw)
References: <19980508233604.14173.qmail@crowfix.com>

Hi!

I am no expert but this works for me.

 try
        {

       Connection
conn=DriverManager.getConnection("jdbc:postgresql://myserver:5432/mydb","userName","password");

       Statement  stmt = conn.createStatement();
       ResultSet   rest = stmt.executeQuery("select  last_value from cid ");
        while (rest.next())
               int   myint =   rest.getInt(1);
        }
        catch(SQLException  sqle)
        {
            sqle.printStackTrace();
           }

        bla bla bla again.....

on psql if you go type       select * from mysequence;

you will see what variables you can access. I am not sure it is last_value or last
value or current value.
sorry!!!
Hope this helps.


Anil


Felix Morley Finch wrote:

> I am a somewhat newbie with java and sql.  I've run into something
> that seems odd, maybe even wrong (!).
>
>         Statement seq = db.createStatement ();
>         seq.execute ("SELECT nextval ('cdid')");
>         ResultSet rs = seq.getResultSet ();
>         id = rs.getInt (0 + 1);                 <=========






view thread (2+ messages)

Message-ID: <3553E222.1DFF7079@awcoldstream.com>
Permalink:  ../3553E222.1DFF7079@awcoldstream.com/
Also on:    postgresql.org/message-id/3553E222.1DFF7079@awcoldstream.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: anil@server.awcoldstream.com, felix@crowfix.com
  Subject: Re: [INTERFACES] jdbc can't getResult of "select nextval (seq_name)"
  In-Reply-To: <3553E222.1DFF7079@awcoldstream.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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