title: Displaying data from database in JList
body: <p>I am using following code for retrieving data from database, but i don't know how to show it in <code>JList</code></p>
  
  <pre><code>Class.forName("oracle.jdbc.driver.OracleDriver");
  Statement stmt = null;
  ResultSet rs;                                                                          
  Connection conn=DriverManager.getConnection("jdbc:mysql://127.0.0.1/SPL","root","PWD");
  stmt=(Statement) conn.createStatement();
  rs=stmt.executeQuery(query);
  while (rs.next()) 
  {
      String stadium = rs.getString("Stadium");
      String city = rs.getString("City");
  }
  </code></pre>
  
  <p>But i want to show column data in <code>JList</code>. Can you guys tell me how to do that?</p>
  
  <hr>
  
  <p>i am using the following code but it is not displaying anything on my frame, can you please tell me where i am wrong? Thanks</p>
  
  <pre><code> String query="SELECT * FROM Location";
   DefaultListModel model=new DefaultListModel();
   DefaultListModel model1=new DefaultListModel();
   try
   {                                              Class.forName("oracle.jdbc.driver.OracleDriver");
  Statement stmt = null;
  ResultSet rs;                                                                          
  Connection conn=DriverManager.getConnection("jdbc:mysql://127.0.0.1/SPL","root","PWD");
  stmt=(Statement) conn.createStatement();
  rs=stmt.executeQuery(query);
  while (rs.next()) 
  {
  String stadium = rs.getString("Stadium");
  String city = rs.getString("City");
  model.addElement(stadium);
  model1.addElement(city);
  }
  JList list=new JList(model);
  JList list1=new JList(model1);
  f8.add(jpa1); //f8=frame name,jpa1=panel name
  jpa1.add(list);                                 list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);                        list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
  list.setVisibleRowCount(1);
  JScrollPane listScroller = new JScrollPane(list);                                          
  }
  catch(SQLException e)
  {
  System.out.println("Message   : " + e.getMessage());
  }
  </code></pre>