package javabook;
import java.sql.*;
public class Example 9_1 {
    public static void main(String[] args) {
        Connection con = null;                               // 定义数据库连接对象
        Statement st = null;
        ResultSet rs = null;
        try{                                              
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");   // 加载JDBC-ODBC桥接器
        }catch(Exception e) {
              System.out.println("" + e); 
        }
        try {
              con = DriverManager.getConnection("jdbc:odbc:sun","","");  // 创建数据库连接对象
              st = con.createStatement();                          // 创建执行SQL语句对象
              rs = st.executeQuery("select * from goodsStore order by priceOut");  
	             System.out.println("库存商品按销售价格排序显示如下");
              while (rs.next()) {
		   String code = rs.getString(1);
		   String name = rs.getString(2);
		   double priceIn = rs.getDouble(3);
		   double priceOut = rs.getDouble(4);
		   int stock = rs.getInt(5);
          System.out.println("-"+code+"---"+name+"--"+price+"--"+sale+"--"+stock+"-");
	       }            
	       con.close();                                             // 关闭数据库
          }catch (SQLException e1){
		        System.out.println(e1);
         }
    }
}