甘先生Blog

          生活就像一盒巧克力,你永遠不知道你會得到什么

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            59 Posts :: 29 Stories :: 186 Comments :: 0 Trackbacks

          常用鏈接

          留言簿(16)

          我參與的團隊

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

            數據庫表:tblMobile.sql
          建立一個簡單的測試表。
          create table tblMobile (id int, name varchar(20), price decimal(10,2), image varchar(50), categoryid varchar(20)) ;
          insert into tblMobile(1,'hello',200,'1.jpg','moto');



          這里利用一個jsp文件生成xml文件。
          phonelist.jsp



          <?xml version="1.0" encoding="utf-8"?> 
          <%@ page contentType="text/html;charset=utf-8"%> 
          <%@ page import="java.sql.*"%> 
          <phonelist> 
          <% 
              String sql 
          = ""
              String url 
          = ""
           
              String categoryID 
          = request.getParameter("categoryID"); 
               
              
          try 


                  Class.forName(
          "org.hsqldb.jdbcDriver").newInstance();
                  String URL
          ="jdbc:hsqldb:hsql://localhost/xdb";
                  String user
          ="sa";
                  String password
          ="";
                  Connection conn 
          = DriverManager.getConnection(URL,user,password);

                  
                  Statement stmt 
          = conn.createStatement(); 
           
                   
                  String strOut 
          = new String(categoryID.getBytes("ISO8859-1"), "GBK");  
           
                  System.out.println(
          "categoryID="+categoryID); 
                  System.out.println(
          "categoryID="+strOut); 
           
                  sql 
          = "select id, name, price, image from tblMobile where categoryid='" + strOut + "'"
                  ResultSet rs 
          = stmt.executeQuery(sql); 
           
                  
          while (rs.next())
                      out.println(
          "<phone id=\"" + rs.getString(1) + "\">"); 
                      out.println(
          "<id>" + rs.getString(1+ "</id>"); 
                      out.println(
          "<name>" + rs.getString(2+ "</name>"); 
                      out.println(
          "<price>" + rs.getString(3+ "</price>"); 
                      out.println(
          "<image>" + rs.getString(4+ "</image>"); 
                      out.println(
          "</phone>"); 
                  }
           
           
                  rs.close(); 
                  stmt.close(); 
                  conn.close(); 
           
              }
           catch (Exception e) 
                  out.println(e); 
              }
           
          %> 
          </phonelist> 


          test.lzx

          <canvas height="100" width="500" >
            
          <dataset name="myData" autorequest="true" type="http" src="phonelist.jsp?categoryID=moto"/>

            
          <simplelayout axis="y"/>

              
          <view datapath="myData:/phonelist/phone">
                  
          <simplelayout axis="x"/>
                
          <text datapath="image/text()" /> 
                
          <text datapath="name/text()" />
              
          </view>

          </canvas>



          posted on 2005-11-28 09:59 甘先生 閱讀(1546) 評論(2)  編輯  收藏 所屬分類: JavaRIA
          主站蜘蛛池模板: 图木舒克市| 平原县| 肥城市| 桦甸市| 图木舒克市| 汉寿县| 曲周县| 台山市| 达日县| 安平县| 无为县| 两当县| 乌鲁木齐市| 阳城县| 左权县| 太仆寺旗| 崇信县| 庆阳市| 陆河县| 芒康县| 晋宁县| 沈丘县| 呼伦贝尔市| 唐海县| 巧家县| 绥宁县| 东台市| 房产| 清新县| 饶河县| 双流县| 武义县| 甘孜县| 文化| 内黄县| 绵竹市| 贵阳市| 八宿县| 余姚市| 江油市| 雷山县|