http://www-900.ibm.com/developerWorks/cn/java/j-jtp08223/index.shtml

解决方案 »

  1.   

    public class MyDB
    {
      private int year;
      private String str;
      public MyDB(int ye,String s)
      {
          year=ye;
          str=s;
      }
    }public Collection getDB()
    {
       List cars=new ArrayList();
       Connection conn=null;
       Statement stat=null;
       ResultSet rs=null;
       
       try(
       conn=dataSource.getConnection();
       stat=conn.createStatement();
       rs=stat.executeQuery("sql语句");
         while(rs.next())
         {
            int year=rs.getInt("1");
            String str=rs.getString("2");
          cars.add(new MyDB(year,str));
         }
         return cars;
       }catch(Exception e0
       {
          e.printStackTrace();
       }
    }
      

  2.   

    不太清楚楼主的意思
    放到hashmap的话,要求键-值对能唯一确定
    如果你不同记录对应的一个图的话,你怎么往hashmap里放?
      

  3.   

    http://www.zdnet.com.cn/developer/code/story/0,2000081534,39111995,00.htm
    http://www2.tw.ibm.com/developerWorks/tutorial/SelectTutorial.do?tutorialId=182
    帮你找了两篇文章,希望对你有用/
      

  4.   

    HashMap hash=new HashMap();
    hash.put("asdf","asdfsdf");
    hash.put("asdf","asdfsdf");
    System.out.println(hash.size());//size=1;jdk不报错
    HashMap hash=new HashMap();
    hash.put("asdf1","图1");
    hash.put("asdf2","图1");