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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-interfaces by date

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