Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Problems with nextval and currval calling JAVA and Oracle 9i

Problems with nextval and currval calling JAVA and Oracle 9i

From: Alexander Vogl <info_at_agrv.de>
Date: 22 Jan 2004 05:38:49 -0800
Message-ID: <7ad87e73.0401220538.37c40c64@posting.google.com>


Hello,

need some Help.
I'm will insert some data into some different tables at an Oracle 9i Database.
Now I have create following sequence:
>>> CREATE SEQUENCE fid_seq start with 1

Now I have to access via JAVA to the sequence. Here the code of the 2 methodes I'm using: <snip>

public static int getNextval_fid()

    {

        String query = "select fid_seq.nextval from dual ";
        int val = 0;
        try
        {
            Connection cn = MakeConnection.get_connection();
            PreparedStatement stmt = cn.prepareStatement(query);
            ResultSet result = stmt.executeQuery();
            while (result.next())
            {
                val = result.getInt(1);
                System.out.println(val);
            }
            result.close();
            stmt.close();
            cn.close();
             System.out.println("fid_nextval:"+val);
        }
        catch (SQLException e)
        {
            LogMsg.dbError(query, e, "SequenceBean::getNextval_fid");
        }
        return val;

    }

   public static int getNextval_fid()
    {

        String query = "select fid_seq.nextval from dual ";
        int val = 0;
        try
        {
            Connection cn = MakeConnection.get_connection();
            PreparedStatement stmt = cn.prepareStatement(query);
            ResultSet result = stmt.executeQuery();
            while (result.next())
            {
                val = result.getInt(1);
                System.out.println(val);
            }
            result.close();
            stmt.close();
            cn.close();
             System.out.println("fid_nextval:"+val);
        }
        catch (SQLException e)
        {
            LogMsg.dbError(query, e, "SequenceBean::getNextval_fid");
        }
        return val;

    }

</snip>

The problem is, that i can get the nextval but not the currval. To get these values I'm using these calls:

int fid_nextval = SequenceBean.getNextval_fid(); int fid_currval = SequenceBean.getCurrval_fid();

Here I get the Value for fid_nextval but no value for fid_currval.

Some Ideas to handle these problem ?

Thank you

Alexander Received on Thu Jan 22 2004 - 07:38:49 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US