日期:2014-05-17 浏览次数:20638 次
<div class="center_right" > <table border = "1" style = "border:1px solid red;size: 12px;color: green"> <tr> <td>产品标号</td><td>供应商编号</td><td>产品名称</td><td>产品价格</td> <td>产品数量</td><td>产品描述</td> </tr> <% /*jdbc连接数据库*/ String driverName = "com.mysql.jdbc.Driver"; String url = "jdbc:mysql://localhost:3306/commo?"; String user = "root"; String passWord = "123456"; try{ Class.forName(driverName); java.sql.Connection conne = java.sql.DriverManager.getConnection(url,user,passWord); java.sql.Statement state = conne.createStatement(); java.sql.ResultSet rs = state.executeQuery("SELECT * FROM products"); while(rs.next()){ %> <tr> <td><%=rs.getInt(1)%></td> <td><%=rs.getInt(2)%></td> <td><%=rs.getString(3)%></td> <td><%=rs.getDouble(4)%></td> <td><%=rs.getInt(5)%></td> <td><%=rs.getString(6)%></td> </tr> <% } }catch(Exception e){ e.printStackTrace(); } %> </table> </div>