Project

General

Profile

« Previous | Next » 

Revision 1136

Added by Jing Tao almost 22 years ago

Change back to pass Connection a parameter.

View differences:

SqlserverAdapter.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
    try
60
    {
61
      //check out DBConnection
62
      conn=DBConnectionPool.getDBConnection("SqlserverAdapter.getUniqueID");
63
      serialNumber=conn.getCheckOutSerialNumber();
64
      stmt = conn.createStatement();
65
      stmt.execute("SELECT @@IDENTITY");
66
      ResultSet rs = stmt.getResultSet();
67
      if ( rs.next() ) {
57
    stmt = conn.createStatement();
58
    stmt.execute("SELECT @@IDENTITY");
59
    ResultSet rs = stmt.getResultSet();
60
    if ( rs.next() ) {
68 61
        uniqueid = rs.getLong(1);
69
      }
62
    }
70 63
      stmt.close();
71
    }
72
    finally
73
    {
74
      DBConnectionPool.returnDBConnection(conn, serialNumber);
75
    }
76
    //System.out.println("Unique ID: " + uniqueid);    
64

  
77 65
    return uniqueid;
78 66
  }
79 67

  

Also available in: Unified diff