Skip site navigation (1) Skip section navigation (2)

Re: [INTERFACES] jdbc can't getResult of "select nextval (seq_name)"

From: Anil Amarakoon <anil(at)server(dot)awcoldstream(dot)com>
To: Felix Morley Finch <felix(at)crowfix(dot)com>
Cc: "pgsql-interfaces(at)postgreSQL(dot)org" <pgsql-interfaces(at)postgreSQL(dot)org>
Subject: Re: [INTERFACES] jdbc can't getResult of "select nextval (seq_name)"
Date: 1998-05-09 04:57:06
Message-ID: 3553E222.1DFF7079@awcoldstream.com (view raw or flat)
Thread:
Lists: pgsql-interfaces
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);                 <=========




In response to

pgsql-interfaces by date

Next:From: Byron NikolaidisDate: 1998-05-10 00:12:21
Subject: Re: [INTERFACES] NEW ODBC DRIVER
Previous:From: Stephen DaviesDate: 1998-05-09 02:17:25
Subject: New ODBC release

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group