Project

General

Profile

« Previous | Next » 

Revision 161

Added by bojilova almost 24 years ago

docid is String
docid is generated from AccessionNumber.generate() call

View differences:

src/edu/ucsb/nceas/metacat/DBSAXDocument.java
25 25
    private String          docname;
26 26
    private String          doctype;
27 27
    private String          doctitle;
28
    private long            docid;
28
    private String          docid;
29 29

  
30 30
    /** 
31 31
     * Construct a new document instance
......
60 60
          pstmt = conn.prepareStatement(
61 61
                "INSERT INTO xml_documents " +
62 62
                "(docid, rootnodeid, docname, doctype) " +
63
                "VALUES (null, ?, ?, ?)");
63
                "VALUES (?, ?, ?, ?)");
64 64

  
65 65
          // Bind the values to the query
66
          pstmt.setLong(1, rootnodeid);
67
          pstmt.setString(2, docname);
68
          pstmt.setString(3, doctype);
66
          this.docid = AccessionNumber.generate(null, "INSERT");
67
          pstmt.setString(1, this.docid);
68
          pstmt.setLong(2, rootnodeid);
69
          pstmt.setString(3, docname);
70
          pstmt.setString(4, doctype);
69 71
          // Do the insertion
70 72
          pstmt.execute();
71 73
          pstmt.close();
72

  
74
/*
73 75
          long assigned_id=0;
74 76
          Statement stmt;
75 77
          stmt = conn.createStatement();
......
81 83
            this.docid = assigned_id;
82 84
          }
83 85
          stmt.close();
84

  
86
*/
85 87
        } catch (SQLException e) {
86 88
          System.out.println(e.getMessage());
89
        } catch (Exception e) {
90
          System.out.println(e.getMessage());
87 91
        }
88 92
    }
89 93

  
90 94
    /** Get doc id */
91
    public long getDocID() {
95
    public String getDocID() {
92 96
      return docid;
93 97
    }
94 98

  
......
115 119

  
116 120
        // Bind the values to the query
117 121
        pstmt.setString(1, doctitle);
118
        pstmt.setLong(2, docid);
122
        pstmt.setString(2, docid);
119 123

  
120 124
        // Do the insertion
121 125
        pstmt.execute();

Also available in: Unified diff