Project

General

Profile

« Previous | Next » 

Revision 2446

Added by sgarg over 19 years ago

Removed occurence of enum which is a keyword in Java 1.5

Changed the queries so that PreparedStatement.setString() and .setInt() are used instead of write the string directly into the sql statements

View differences:

src/edu/ucsb/nceas/metacat/DBQuery.java
625 625
                            .getOption("xml_returnfield_count")))
626 626
                            .intValue();
627 627

  
628
     // set enterRecords to true if usage_count is more than the offset 
628
     // set enterRecords to true if usage_count is more than the offset
629 629
     // specified in metacat.properties
630 630
     if(usage_count > count){
631 631
         enterRecords = true;
......
682 682
         key = (String) keys.nextElement();
683 683
         element = (String)partOfDoclist.get(key);
684 684

  
685
	 // check if the enterRecords is true, elements is not null, element's 
686
         // length is less than the limit of table column and if the document 
685
	 // check if the enterRecords is true, elements is not null, element's
686
         // length is less than the limit of table column and if the document
687 687
         // has been indexed already
688
         if(enterRecords && element != null 
688
         if(enterRecords && element != null
689 689
		&& element.length() < offset
690 690
		&& element.compareTo((String) partOfDoclistBackup.get(key)) != 0){
691 691
             query = "INSERT INTO xml_queryresult (returnfield_id, docid, "
692
                 + "queryresult_string) VALUES ('" + returnfield_id
693
                 + "', '" + key + "', '" + element + "')";
692
                 + "queryresult_string) VALUES (?, ?, ?)";
693

  
694 694
             PreparedStatement pstmt = null;
695 695
             pstmt = dbconn.prepareStatement(query);
696
             pstmt.setInt(1, returnfield_id);
697
             pstmt.setString(2, key);
698
             pstmt.setString(3, element);
699

  
696 700
             dbconn.increaseUsageCount(1);
697 701
             pstmt.execute();
698 702
             pstmt.close();
......
809 813
       String returnfield = qspec.getSortedReturnFieldString();
810 814

  
811 815
       // query for finding the id from xml_returnfield
812
       String query = "select returnfield_id, usage_count from xml_returnfield "
813
           + "where returnfield_string like '" + returnfield +"'";
816
       String query = "SELECT returnfield_id, usage_count FROM xml_returnfield "
817
            + "WHERE returnfield_string LIKE ?";
814 818
       MetaCatUtil.debugMessage("ReturnField Query:" + query, 50);
815 819

  
816 820
       try {
817 821
           // prepare and run the query
818 822
           pstmt = dbconn.prepareStatement(query);
823
           pstmt.setString(1,returnfield);
819 824
           dbconn.increaseUsageCount(1);
820 825
           pstmt.execute();
821 826
           rs = pstmt.getResultSet();
......
846 851

  
847 852
               // insert a new record
848 853
               query = "INSERT INTO xml_returnfield (returnfield_string, usage_count)"
849
                   + "VALUES ('" + returnfield + "', '1')";
854
                   + "VALUES (?, '1')";
850 855
               MetaCatUtil.debugMessage("ReturnField Table Insert:"+ query, 50);
851 856
               pstmt = dbconn.prepareStatement(query);
857
               pstmt.setString(1, returnfield);
852 858
               dbconn.increaseUsageCount(1);
853 859
               pstmt.execute();
854 860
               pstmt.close();
855 861

  
856 862
               // get the id of the new record
857
               query = "select returnfield_id from xml_returnfield "
858
                   + "where returnfield_string like '" + returnfield +"'";
859
               MetaCatUtil.debugMessage("ReturnField query after Insert:"
860
                                        + query, 50);
863
               query = "SELECT returnfield_id FROM xml_returnfield "
864
                   + "WHERE returnfield_string LIKE ?";
865
               MetaCatUtil.debugMessage("ReturnField query after Insert:" + query, 50);
861 866
               pstmt = dbconn.prepareStatement(query);
867
               pstmt.setString(1, returnfield);
868

  
862 869
               dbconn.increaseUsageCount(1);
863 870
               pstmt.execute();
864 871
               rs = pstmt.getResultSet();
......
1189 1196
     */
1190 1197
    private Vector getElements(Vector parentidList)
1191 1198
    {
1192
        Vector enum = new Vector();
1199
        Vector enumVector = new Vector();
1193 1200
        Vector tempVector = null;
1194 1201

  
1195 1202
        for (int count = 0; count < parentidList.size(); count++) {
1196 1203
            tempVector = (Vector) parentidList.get(count);
1197 1204

  
1198
            enum.add(tempVector.get(1));
1205
            enumVector.add(tempVector.get(1));
1199 1206
        }
1200
        return enum;
1207
        return enumVector;
1201 1208
    }
1202 1209

  
1203 1210
    /*

Also available in: Unified diff