BEA Systems, Inc.

WebLogic Server 5.1.0 API Reference

weblogic.db.jdbc.oracle
Class Sequence

java.lang.Object
  |
  +--weblogic.db.jdbc.oracle.Sequence

public final class Sequence
extends java.lang.Object

A Sequence object is a wrapper for Oracle sequences.

This example shows how to create, use, and drop a Sequence that starts at 10 and is incremented by 1.

   // Create a Sequence that starts at 10 and is incremented by 1.
   Sequence.create(conn, "seq1", 10, 1);
 
Sequence seq = new Sequence(conn, "seq1");
// Generate 10 numbers from Sequence for (int i = 0; i < 10; i++) System.out.println("Next value = " + seq.nextValue());
// Print last value of Sequence System.out.println("Current value of sequence is: " + seq.currentValue());
// Drop the Sequence Sequence.drop(conn, "seq1");
For implementation and usage, see the dbKona Developers Guide.

Author:
Copyright (c) 1995-1998 by WebLogic, Inc. All Rights Reserved., Copyright (c) 1998-1999 by BEA Systems, Inc. All Rights Reserved.
Copyright © 2000 BEA Systems, Inc. All Rights Reserved.

Constructor Summary
Sequence(java.sql.Connection conn, java.lang.String seqname)
          Constructs a Sequence with the specified JDBC Connection.
 
Method Summary
 void close()
          Closes a Sequence and frees its resources.
 java.sql.Connection connection()
          Returns the Connection associated with a Sequence.
static void create(java.sql.Connection conn, java.lang.String seqname, int increment, int start)
          Creates a sequence of the specified name on an Oracle server with the specified start value and increment value.
 int currentValue()
          Returns the current value of a Sequence object.
static void drop(java.sql.Connection conn, java.lang.String seqname)
          Drops a sequence from an Oracle server.
 java.lang.String name()
          Returns the name of the Oracle sequence that is associated with a Sequence object.
 int nextValue()
          Returns the next value of a Sequence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sequence

public Sequence(java.sql.Connection conn,
                java.lang.String seqname)
         throws java.sql.SQLException,
                DataSetException
Constructs a Sequence with the specified JDBC Connection. The second argument is the name of an Oracle sequence that exists on the server.

Parameters:
conn - java.sql.Connection object
seqname - Name of an Oracle sequence that exists
Throws:
java.sql.SQLException - if there is a SQL error
DataSetException - if there is a data error
Method Detail

close

public void close()
           throws java.sql.SQLException,
                  DataSetException
Closes a Sequence and frees its resources.

Throws:
java.sql.SQLException - if there is a SQL error
DataSetException - if there is a data error

name

public java.lang.String name()
Returns the name of the Oracle sequence that is associated with a Sequence object.

Returns:
Name associated with a Sequence

connection

public java.sql.Connection connection()
Returns the Connection associated with a Sequence.

Returns:
Connection object

currentValue

public int currentValue()
                 throws DataSetException,
                        java.sql.SQLException
Returns the current value of a Sequence object. Sequence.currentValue() will fail unless Sequence.nextValue() has already been called in the same Connection.

Returns:
Current Sequence value
Throws:
java.sql.SQLException - if there is a SQL error
DataSetException - if there is a data error
See Also:
nextValue()

nextValue

public int nextValue()
              throws DataSetException,
                     java.sql.SQLException
Returns the next value of a Sequence.

Returns:
Next Sequence value
Throws:
java.sql.SQLException - if there is a SQL error
DataSetException - if there is a data error
See Also:
currentValue()

create

public static void create(java.sql.Connection conn,
                          java.lang.String seqname,
                          int increment,
                          int start)
                   throws java.sql.SQLException,
                          DataSetException
Creates a sequence of the specified name on an Oracle server with the specified start value and increment value. Use Sequence.drop() to drop a sequence.

Parameters:
conn - java.sql.Connection object
seqname - Sequence name
increment - Sequence increment
start - Start value of Sequence
Returns:
Sequence object
Throws:
java.sql.SQLException - if there is a SQL error
DataSetException - if there is a data error
See Also:
drop(java.sql.Connection, java.lang.String)

drop

public static void drop(java.sql.Connection conn,
                        java.lang.String seqname)
                 throws java.sql.SQLException
Drops a sequence from an Oracle server. Use Sequence.create() to add a sequence.

Parameters:
conn - java.sql.Connection object
Throws:
java.sql.SQLException - if there is a SQL error
See Also:
create(java.sql.Connection, java.lang.String, int, int)

Documentation is available at
http://www.weblogic.com/docs51