nextval ('sequence') is going to increment your sequence.... Are you sure
you dont want currval ??? Also -- Have you granted select permissions on the
sequence to whatever user your program is running as ???
GP
"Elielson Fontanezi" <ElielsonF@prodam.sp.gov.br> wrote in message
news:A799F7647794D311924A005004ACEA9709699311@cprodamibs249.prodam...
> Hi Folks!
>
> I need some help.
> See this code parcel:
>
> ...
> ...
> ResultSet rs =3D=20
> 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=B4ve
> created so far,
> but with this sequence no data comes from.
> I am uncapable of guessing what can be.
>
> I=B4d 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 =3D DriverManager.getConnection(
> "jdbc:postgresql://10.10.96.147:5432/suporte",
> "suporte", "suporte");
>
> System.out.println("Connection successful!!");
>
> Statement st =3D con.createStatement();
> =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
> ResultSet rs =3D st.executeQuery(
> "SELECT NEXTVAL('seq_suporte') AS valor");
>
> int novoCodigoSuporte =3D
> rs.getInt("valor");
>
> st.close();
> con.close();
> }
> catch(Exception e)
> {
> e.printStackTrace();
> }
> }
> }
>
>
> +--------------------------------------------------------+
> | _ Elielson Fontanezi (elielsonf@prodam.sp.gov.br) |
> | =B0v=B0 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 4: Don't 'kill -9' the postmaster