Kira-2006
          -僅僅是一陣風也罷了,偏偏是這樣永恒, 僅僅是一場夢也罷了,偏偏是如此的真實,
          posts - 4,comments - 7,trackbacks - 0

          使用Ant操作hsql數據庫的例子:

          <?xml version="1.0"?>

          <project name="timexdb">
           <property name="hjar" value="WebRoot/WEB-INF/lib/hsqldb.jar" />
           <property name="hclass" value="org.hsqldb.Server" />
           <property name="hfile" value="-database.0 data/gogoudb" />
           <property name="halias" value="gogou" />
           <property name="hport" value="9005" />

           <target name="starthsql">
            <java fork="true"
             classname="${hclass}"
             classpath="${hjar}"
             args="${hfile} -dbname.0 ${halias} -port ${hport}" />
           </target>

           <target name="execddl">
            <sql classpath="${hjar}"
             driver="org.hsqldb.jdbcDriver"
             url="jdbc:hsqldb:hsql://localhost:${hport}/${halias}"
             userid="sa"
             password=""
             print="yes">

          -- SQL script for TimeX
          -- Step 1: Drop objects if they exist
          DROP TABLE Department IF EXISTS;
          DROP TABLE Employee IF EXISTS;
          DROP TABLE Timesheet IF EXISTS;
          DROP INDEX TimesheetIndex IF EXISTS;
          DROP INDEX DepartmentCodeIndex IF EXISTS;
          DROP INDEX EmployeeIdIndex IF EXISTS;
          DROP TABLE customer IF EXISTS;
          DROP TABLE Item IF EXISTS;
          DROP TABLE Item_subType IF EXISTS;
          DROP TABLE Item_superType IF EXISTS;
          DROP TABLE orders IF EXISTS;
             
          -- Step 2: Create tables
          CREATE TABLE Item_superType
          (
             superID BIGINT primary key,
             superTypeName VARCHAR(20) NOT NULL
          );

          CREATE TABLE Item_subType
          (
             subID BIGINT primary key,
             superID BIGINT,
             subTypeName VARCHAR(20) NOT NULL,
             FOREIGN KEY(superID) REFERENCES Item_superType(superID)
          );

          CREATE TABLE Item
          (
             itemID BIGINT primary key,
             subID BIGINT,
             itemName VARCHAR(20) NOT NULL,
             Introduce VARCHAR(50) ,
             Price VARCHAR(6) NOT NULL,
             nowPrice VARCHAR(6) NOT NULL,
             smallPicture VARCHAR(10) NOT NULL,
             bigPicture VARCHAR(10) NOT NULL,
             inTime datetime ,
             newItem INT ,
             Rebate INT ,
             Hit INT ,
             FOREIGN KEY(subID) REFERENCES Item_subType(subID)
          );

          CREATE TABLE customer
          (
              userID BIGINT IDENTITY,
              username VARCHAR(20) NOT NULL,
              Password  VARCHAR(20) NOT NULL,
              userCity  VARCHAR(20) ,
              userEmail  VARCHAR(20) NOT NULL,
              userAge  INT ,
              userSex  INT
           );
               
          CREATE TABLE orders
          (
           orderID BIGINT IDENTITY,
              consigneeName VARCHAR(20) NOT NULL,
              consigneeAddress VARCHAR(20) NOT NULL,
              Postalcode VARCHAR(6) NOT NULL,
              Telephone VARCHAR(20) NOT NULL,
              carryMethod VARCHAR(10) NOT NULL,
              Orderdate  datetime  
          );
                 
          CREATE TABLE visualOrder
          (
               id BIGINT  IDENTITY,
               itemID BIGINT,
               userID BIGINT,
               orderID BIGINT,
               itemNumber BIGINT NOT NULL,
               FOREIGN KEY(itemID) REFERENCES Item(itemID),
               FOREIGN KEY(userID) REFERENCES customer(userID),
               FOREIGN KEY(orderID) REFERENCES orders(orderID)
          );

          -- Step 3: Create indexes
          CREATE UNIQUE INDEX visualOrderIndex ON visualOrder (userID);
          CREATE UNIQUE INDEX ItemIndex ON Item (itemID);
          CREATE UNIQUE INDEX userIdIndex ON customer (userId);
             
          create view newItem_statistic as  select * from item where item.newItem = 1;
          create view saleItem_statistic as  select * from item where item.Rebate = 1;

          -- Step 4: Insert some reference and test data
          INSERT INTO customer (userName, Password,userEmail)
                  VALUES ('kira', 'kira','xuguoliang@sina.com');


          -- Step 5: Verify tables and test data look ok
          SELECT * FROM customer;

                </sql>
           </target>
           <target name="hsqldm">
            <java fork="true" classpath="${hjar}" classname="org.hsqldb.util.DatabaseManagerSwing" />
           </target>
           <target name="sqltool">
            <java fork="true" classpath="${hjar}" classname="org.hsqldb.util.SqlTool" args="localhost-sa" />
           </target>
          </project>

          posted on 2008-04-26 18:25 Kira-2006 閱讀(302) 評論(0)  編輯  收藏 所屬分類: hsql

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 腾冲县| 盐源县| 灵丘县| 瑞金市| 元氏县| 荣昌县| 潼关县| 延吉市| 万盛区| 大渡口区| 读书| 阜城县| 望都县| 平武县| 卫辉市| 汾阳市| 青铜峡市| 白水县| 龙海市| 平利县| 宁陵县| 凤翔县| 南京市| 奎屯市| 图们市| 蓬安县| 思茅市| 政和县| 简阳市| 迭部县| 廊坊市| 砀山县| 米泉市| 辽阳市| 长岭县| 池州市| 乡宁县| 建平县| 北票市| 高雄县| 岑溪市|