关于java数据库的问题
想请教下java如何实现点击按钮后,数据库某一个表的结果显示在文本框中,下面是我数据库的实现代码:程序代码:
public static void furnitureinfo() throws SQLException{ DriverManager.registerDriver(new com.mysql.jdbc.Driver()); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/furniture","root","toor"); java.sql.Statement stmt = conn.createStatement(); java.sql.ResultSet rs = stmt.executeQuery("select * from funiture_infornation;"); List<Furniture_info> us = new ArrayList<Furniture_info>(); String s[] = new String[3]; while(rs.next()){ Furniture_info furniture = new Furniture_info(); furniture.setFuniture_id(rs.getInt("funiture_id")); furniture.setFuniture_name(rs.getString("funiture_name")); furniture.setFurniture_price(rs.getInt("Furniture_price")); furniture.setSupplier_id(rs.getInt("supplier_id")); furniture.setBrands(rs.getString("Brands")); furniture.setFurniture_material(rs.getString("Furniture_material")); furniture.setText(rs.getString("Text")); us.add(furniture); } for(Furniture_info furniture:us){ System.out.println(furniture); } }
刚学java,求解。。。:)