Project

General

Profile

« Previous | Next » 

Revision 1134

Added by Jing Tao over 22 years ago

Change back to pass connection as a parameter. Because new connection will cause an error.

View differences:

src/edu/ucsb/nceas/dbadapter/OracleAdapter.java
50 50
   *            during the db operation
51 51
   * @return return the generated unique id as a long type
52 52
   */
53
  public long getUniqueID(String tableName) 
53
  public long getUniqueID(Connection conn, String tableName) 
54 54
                                         throws SQLException {
55 55
    long uniqueid = 0;
56
    DBConnection conn = null;
57
    int serialNumber = -1;
58 56
    Statement stmt = null;
59 57
    
60
    try
61
    {
62
      //check out DBConnection
63
      conn=DBConnectionPool.getDBConnection("OracleAdapter.getUniqueID");
64
      serialNumber=conn.getCheckOutSerialNumber();
65
      stmt = conn.createStatement();
66
      stmt.execute("SELECT " + tableName + "_id_seq.currval FROM dual");
67
      ResultSet rs = stmt.getResultSet();
68
      if ( rs.next() ) {
58
  
59
     stmt = conn.createStatement();
60
     stmt.execute("SELECT " + tableName + "_id_seq.currval FROM dual");
61
     ResultSet rs = stmt.getResultSet();
62
     if ( rs.next() ) {
69 63
        uniqueid = rs.getLong(1);
70
      }
71
      stmt.close();
72
    }
73
    finally
74
    {
75
      DBConnectionPool.returnDBConnection(conn, serialNumber);
76
    }
77
    //System.out.println("Unique ID: " + uniqueid);    
78
    return uniqueid;
64
     }
65
     stmt.close();
66
 
67
     return uniqueid;
79 68
  }
80 69

  
81 70
  /**

Also available in: Unified diff