2016-05-06 5 views
0

データベーステーブルsupply_locationからArrayListのロケーション名を取得したいとします。しかし、私はエラーを持っている:Error:java.sql.SQLFeatureNotSupportedExceptionデータベースからArraylistを取得する場合

java.sql.SQLFeatureNotSupportedException

VendorBean:

public class VendorBean { 
    private String supplyLocation[]; 

    public void setSupplyLocation(String[] supplyLocation) { 
     this.supplyLocation=supplyLocation; 
    } 
    public String[] getSupplyLocation() { 
     return supplyLocation; 
    } 
} 

DAO:

public List<VendorBean> getLocation(String supplyLocation) throws SQLException { 

     ArrayList<VendorBean> SupplyLocation = new ArrayList<VendorBean>(); 

     try { 
      String userID = supplyLocation; 
      con = DBConnection.getConnection(); 
      String query = "SELECT location_name FROM supply_location AS sl\n" + 
            "LEFT JOIN user_signup AS us \n" + 
            "ON sl.user_id = us.user_id WHERE us.user_id = ?"; 
      ps = con.prepareStatement(query); 
      ps.setString(1, userID); 
      rs = ps.executeQuery(); 

      while(rs.next()) { 
       VendorBean supplyLoc = new VendorBean(); 
       Array a = rs.getArray("location_name"); 
       String[] location = (String[])a.getArray(); 

       supplyLoc.setSupplyLocation(location); 
       SupplyLocation.add(supplyLoc); 
      } 
     } 
     finally { 
      try { 
       if(rs!=null) { 
        rs.close(); 
       } 
       if (ps!=null) { 
        ps.close(); 
       } 
       if(con!=null) { 
        con.close(); 
       } 
      } catch (SQLException ex) { 
        //ignore 
      } 
     } 
     return SupplyLocation; 
    } 

私はこの形式でデータベースからLOCATION_NAMEを取得したい:

1. location_name1 
2. location_name2 
3. location_name3 
4. location_name4 
5. location_name5 

私はこの問題の多くの時間を検索しましたが、適切な解決策を得られませんでした。誰か助けてください。

ありがとうございます!

+0

が重複する可能性に疑問を見る(http://stackoverflow.com/questions/11735786/sqlfeaturenotsupportedexception-on-getarray) –

答えて

関連する問題