| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 
 |  
public ArrayList<String> getDataDBParam( String query, ArrayList<String> Param)
   {
       ArrayList<String> arralist = new ArrayList<String> ();
 
       PreparedStatement pstmt;
       try {
           pstmt= (PreparedStatement)conn.prepareStatement(query);
 
           for (int i= 1; i<arralist.size();i++){
              pstmt.setString(i, arralist.get(i-1));
 
           }
           rs = pstmt.executeQuery();
       }
        catch (SQLException e) {
 
            System.out.println("SQLException : " + e.getMessage());
            System.out.println("SQLState : " + e.getSQLState());
            System.out.println("VendorError : " + e.getErrorCode());
         }
 
          try {
            ResultSetMetaData rsmd = rs.getMetaData();
            int nbCols = rsmd.getColumnCount();
 
            while(rs.next()) {
                for(int i = 0; i < nbCols; i++) {
                    arralist.add(rs.getString(i+1));
                }
          }                      
        }
        catch (SQLException sql) {
           System.out.println("SQLException : " + sql.getMessage());
            System.out.println("SQLState : " + sql.getSQLState());
            System.out.println("VendorError : " + sql.getErrorCode());
        }
 
       return arralist;
 
   } |