Creating a sequence - Mailing list pgsql-jdbc

From Chris
Subject Creating a sequence
Date
Msg-id eac7b0710804230646l5c972dafm6db2369e62e6dcc2@mail.gmail.com
Whole thread Raw
Responses Re: Creating a sequence
List pgsql-jdbc
I have an existing table that I need to get the last record number and increment it.  I've read that I need to create a sequence first, but I'm not sure how to go about doing that with an existing table.  Here is the code I have so far:

        try {
            s = conn.createStatement();
            log.info("Got Connection");

            empID = s.executeQuery("SELECT nextval(emp_uid) FROM employee");    <--- this is not working
            log.info("Got Employee ID ");
           
            empID.next();
            int newID = empID.getInt(1);
            log.info("New ID = " + newID);
           
            rows = s.executeUpdate("INSERT INTO employee(emp_uid,first_name, last_name, emp_nbr, emp_type_code, emp_status_code, emp_work_center) " +
                    "VALUES ('"+newID+"','"+firstName+"','"+lastName+"','"+empNumber+"','"+empType+"','"+empStatus+"','"+workStation+  "')");

        } catch (SQLException se) {
              log.info("We got an exception while executing our query:" +
                                 "that probably means our SQL is invalid.  " +
                                 se);
              System.exit(1);
        }

Here's the log:

INFO: We got an exception while executing our query:that probably means our SQL is invalidorg.postgresql.util.PSQLException: ERROR: could not open relation with OID 5

What am I missing?

Thank You
Chris

pgsql-jdbc by date:

Previous
From: olafos
Date:
Subject: Query parameters limit in postgres jdbc driver?
Next
From: Craig Ringer
Date:
Subject: Re: Creating a sequence