Re: st.executeQuery("SELECT NEXTVAL('seq_suporte') AS valo - Mailing list pgsql-jdbc

From J M Okomba
Subject Re: st.executeQuery("SELECT NEXTVAL('seq_suporte') AS valo
Date
Msg-id 715DF98A936DD211B29D0008C71E55D49459C7@NTSERVER1
Whole thread Raw
List pgsql-jdbc
Does the sequence 'seq_suporte' exist in your database?

> -----Original Message-----
> From:    Elielson Fontanezi [SMTP:ElielsonF@prodam.sp.gov.br]
> Sent:    03 February 2003 13:13
> To:    pgsql-jdbc; pgsql-general
> Subject:    [JDBC] st.executeQuery("SELECT NEXTVAL('seq_suporte') AS
> valor");
>
> 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.     |
> +--------------------------------------------------------+
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html

pgsql-jdbc by date:

Previous
From: Kris Jurka
Date:
Subject: Re: st.executeQuery("SELECT NEXTVAL('seq_suporte') AS valor");
Next
From: Paul Cullum
Date:
Subject: java.lang.OutOfMemoryError