From: | "codeWarrior" <GPatnude(at)adelphia(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: st.executeQuery("SELECT NEXTVAL('seq_suporte') AS valor"); |
Date: | 2003-02-04 00:40:51 |
Message-ID: | b1n21o$1al6$1@news.hub.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-jdbc |
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(at)prodam(dot)sp(dot)gov(dot)br> wrote in message
news:A799F7647794D311924A005004ACEA9709699311(at)cprodamibs249(dot)prodam(dot)(dot)(dot)
> 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(at)prodam(dot)sp(dot)gov(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | news.verizon.net | 2003-02-04 02:40:23 | Re: FW: Problem starting a session |
Previous Message | Nigel J. Andrews | 2003-02-04 00:37:13 | Re: : How to create stored procedure in PostgreSQL? |
From | Date | Subject | |
---|---|---|---|
Next Message | Kris Jurka | 2003-02-04 01:24:54 | Re: DatabaseMetaData oddities |
Previous Message | Oliver Jowett | 2003-02-03 21:02:56 | Re: DatabaseMetaData oddities |