Project

General

Profile

« Previous | Next » 

Revision 20

Added by Matt Jones over 24 years ago

consolidated table structure to eliminate xml_attributes and xml_elements in favor of a single, unified xml_nodes table

View differences:

DBSAXElement.java
42 42
          PreparedStatement pstmt;
43 43
          if (parent_id != 0) {
44 44
            pstmt = conn.prepareStatement(
45
                "INSERT INTO xml_elements(nodeid, nodename, parentnodeid) " +
46
                "VALUES (null, ?, ?)");
45
                "INSERT INTO xml_nodes (nodeid, nodetype, " +
46
                "nodename, parentnodeid) VALUES (null, ?, ?, ?)");
47 47
          } else {
48 48
            pstmt = conn.prepareStatement(
49
                "INSERT INTO xml_elements(nodeid, nodename) " +
50
                "VALUES (null, ?)");
49
                "INSERT INTO xml_nodes (nodeid, nodetype, nodename) " +
50
                "VALUES (null, ?, ?)");
51 51
          }
52 52

  
53 53
          // Bind the values to the query
54
          pstmt.setString(1, getTagName());// The second ? is for NODENAME
54
          pstmt.setString(1, "ELEMENT");
55
          pstmt.setString(2, getTagName());
55 56
          if (parent_id != 0) {
56
            pstmt.setLong(2, parent_id);
57
            pstmt.setLong(3, parent_id);
57 58
          }
58 59
          // Do the insertion
59 60
          pstmt.execute();
......
72 73
        Statement stmt;
73 74
        try {
74 75
          stmt = conn.createStatement();
75
          stmt.execute("SELECT xml_elements_id_seq.currval FROM dual");
76
          stmt.execute("SELECT xml_nodes_id_seq.currval FROM dual");
76 77
          try {
77 78
            ResultSet rs = stmt.getResultSet();
78 79
            try {
......
140 141
        // And enter the attribute in the database
141 142
        try {
142 143
          PreparedStatement pstmt = conn.prepareStatement(
143
              "INSERT INTO xml_attributes(attributeid, nodeid, " +
144
              "attributename, attributevalue) " +
145
              "VALUES (null, ?, ?, ?)");
144
              "INSERT INTO xml_nodes (nodeid, nodetype, " +
145
              "nodename, nodedata, parentnodeid) VALUES (null, ?, ?, ?, ?)");
146 146

  
147 147
          // Bind the values to the query
148
          pstmt.setLong(1, getElementID());
148
          pstmt.setString(1, "ATTRIBUTE");
149 149
          pstmt.setString(2, attName);
150 150
          pstmt.setString(3, attValue);
151
          pstmt.setLong(4, getElementID());
151 152
 
152 153
          // Do the insertion
153 154
          pstmt.execute();
......
185 186
    public void writeContentToDB() {
186 187
        try {
187 188
          PreparedStatement pstmt = conn.prepareStatement(
188
                "UPDATE xml_elements SET nodedata = ? WHERE nodeid = ?");
189
                "UPDATE xml_nodes SET nodedata = ? WHERE nodeid = ?");
189 190

  
190 191
          // Bind the values to the query
191 192
          pstmt.setString(1, getContent());// The first ? is for NODEDATA

Also available in: Unified diff