jdbc查询数据库返回实体对象集合

最近做prefuse中用到原始的数据库查询

     try {
             ResultSet rs = null;
             String hqltonode="SELECT * FROM report_result_external where device_name='"+m_text+"'"; 
             rs = con.prepareStatement(hqltonode).executeQuery();//查询
             String manage_key="";
             if (rs.next()) {
             manage_key=rs.getString("manage_key");
            }
            // System.out.println( "manage_key"+manage_key); 
             String sql="SELECT * FROM layout WHERE device_name="+"'"+m_text+"' and manage_key='"+manage_key+"'";
            List<String>device_name=new ArrayList<String>();//查询结果集合
            rs = con.prepareStatement(sql).executeQuery();//查询
            String returnde_na="";
            while (rs.next()) {
             System.out.println("查询数据库的数据="+returnde_na);
              returnde_na= rs.getString("device_name");
        }

你可能感兴趣的:(java,服务器后端开发)