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

Поиск
Список
Период
Сортировка
От Anil Amarakoon
Тема Re: [INTERFACES] jdbc can't getResult of "select nextval (seq_name)"
Дата
Msg-id 3553E222.1DFF7079@awcoldstream.com
обсуждение исходный текст
Ответ на jdbc can't getResult of "select nextval (seq_name)"  (Felix Morley Finch <felix@crowfix.com>)
Список 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);                 <=========




В списке pgsql-interfaces по дате отправления:

Предыдущее
От: Stephen Davies
Дата:
Сообщение: New ODBC release
Следующее
От: Felix Morley Finch
Дата:
Сообщение: Problem with jdbc, nextval ('myseq'), and rs.getInt (1) - SOLVED