st.executeQuery("SELECT NEXTVAL('seq_suporte') AS valor");

Поиск
Список
Период
Сортировка
От Elielson Fontanezi
Тема st.executeQuery("SELECT NEXTVAL('seq_suporte') AS valor");
Дата
Msg-id A799F7647794D311924A005004ACEA9709699311@cprodamibs249.prodam
обсуждение исходный текст
Ответы Re: st.executeQuery("SELECT NEXTVAL('seq_suporte') AS valor");  (Kris Jurka <books@ejurka.com>)
Список pgsql-jdbc
Hi Folks!

    I need some help.
    See this code parcel:

    ...
    ...
      ResultSet rs =
        st.executeQuery("SELECT NEXTVAL('seq_suporte') AS valor");
    ...
    ...

    It produces: java.lang.NullPointerException

    What is problem?
    I am used to do SELECT commands like this with any table I´ve
created so far,
but with this sequence no data comes from.
    I am uncapable of guessing what can be.

    I´d appreciate suggestions.

    Below there is a short program that reproduces this case.

Thanks!

-----------------------------------------------------------------
import java.sql.*;

class pgdbping
    {
    public static void main(String args[])
        {
        try
            {
            Class.forName("org.postgresql.Driver");

            Connection con = DriverManager.getConnection(
  "jdbc:postgresql://10.10.96.147:5432/suporte",
  "suporte", "suporte");

            System.out.println("Connection successful!!");

            Statement st = con.createStatement();

            ResultSet rs = st.executeQuery(
               "SELECT NEXTVAL('seq_suporte') AS valor");

            int novoCodigoSuporte =
               rs.getInt("valor");

            st.close();
            con.close();
            }
        catch(Exception e)
            {
            e.printStackTrace();
            }
        }
    }


+--------------------------------------------------------+
|   _    Elielson Fontanezi (elielsonf@prodam.sp.gov.br) |
|  °v°   PRODAM - VSE Department +55 11 5080-9283        |
| /(_)\  May your trails be crooked, winding, lonesome,  |
|  ^ ^   dangerous, leading to the most amazing view.    |
| May your mountains rise into and above the clouds.     |
+--------------------------------------------------------+

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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: DatabaseMetaData oddities
Следующее
От: pginfo
Дата:
Сообщение: Re: Sun J2EE server (default with J2EE package) + PostgreSQL