posts - 165, comments - 198, trackbacks - 0, articles - 1
            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

               摘要: 本文提供:1.企業(yè)分類數(shù)據(jù)2.此類用于吧文本 數(shù)據(jù)變成 sql 并插入數(shù)據(jù)庫(kù) Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> import ?java.io.BufferedReader; im...  閱讀全文

          posted @ 2008-07-15 16:18 G_G 閱讀(1650) | 評(píng)論 (0)編輯 收藏

               摘要: 直接運(yùn)行demo http://www.aygfsteel.com/Files/Good-Game/iba2.rar 數(shù)據(jù)說明: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> /* ?ibatis?...  閱讀全文

          posted @ 2008-07-15 15:37 G_G 閱讀(2007) | 評(píng)論 (0)編輯 收藏

          dome
          使用hsql 數(shù)據(jù)庫(kù);
          一對(duì)多,多對(duì)一;


          可以直接運(yùn)行的 dome:http://www.aygfsteel.com/Files/Good-Game/iba.rar
          本例指涉及到查詢,為了簡(jiǎn)單沒有事務(wù),和service層

          先看測(cè)試運(yùn)行:
          ????@Test
          ????
          public?void?testLevel()?{

          ????????
          try?{

          ????????????Level?level?
          =?(Level)DaoConfig.getSqlMap().queryForObject("level.getLevelId",?new?Integer(2)?);
          ????????????System.out.println(
          "f_level="+level.getFlevel().getName());

          ???????????
          System.out.println("->level="+level.getName());
          ????????????for(Level?ltmp?:?level.getClevel()){
          ????????????????System.out.println(
          "c_root="+ltmp.getName());
          ????????????}
          ????????}?
          catch?(SQLException?e)?{
          ????????????e.printStackTrace();
          ????????}
          ????}


          運(yùn)行結(jié)果:
          hsql 數(shù)據(jù)庫(kù) 初始化
          create
          ?table?level??(?????id?int?not?null,?????name?varchar(80)?null,?????fid?int?,?????constraint?pk_supplier?primary?key?(id),?????constraint?fk_item_1?foreign?key?(fid)?????????references?level?(id)?)?
          create?index?levelName?on?level?(name)?
          insert?into?level?(id,name,fid)?values(1,'root',null)?
          insert?into?level?(id,name,fid)?values(2,'level_1',1)?
          insert?into?level?(id,name,fid)?values(3,'root_2',1)?
          insert?into?level?(id,name,fid)?values(4,'root_1_1',2)?
          insert?into?level?(id,name,fid)?values(5,'root_1_2',2)?
          insert?into?level?(id,name,fid)?values(6,'root_1_1_1',4)

          運(yùn)行結(jié)果
          f_level
          =root
          ->level=level_1
          ????c_level
          =root_1_1
          ????c_level
          =root_1_2


          DaoConfig工具類:
          package?test.persistence;

          import?com.ibatis.common.jdbc.ScriptRunner;
          import?com.ibatis.common.resources.Resources;
          import?com.ibatis.sqlmap.client.SqlMapClient;
          import?com.ibatis.sqlmap.client.SqlMapClientBuilder;

          import?java.io.IOException;
          import?java.io.PrintWriter;
          import?java.io.Reader;
          import?java.sql.Connection;
          import?java.sql.DriverManager;
          import?java.util.Properties;
          /**
          ?*?damo?api
          ?*?
          http://portals.apache.org/bridges/multiproject/jpetstore/apidocs/overview-summary.html
          ?*?
          @author?Administrator
          ?*
          ?
          */
          public?class?DaoConfig?{

          ??
          private?static?SqlMapClient?sqlMap?=?null?;
          ??
          static?{
          ????
          try?{
          ??????Properties?props?
          =?Resources.getResourceAsProperties("properties/database.properties");
          ??????String?url?
          =?props.getProperty("url");
          ??????String?driver?
          =?props.getProperty("driver");
          ??????String?username?
          =?props.getProperty("username");
          ??????String?password?
          =?props.getProperty("password");
          ??????
          if?(url.equals("jdbc:hsqldb:mem:jpetstore"))?{
          ????????Class.forName(driver).newInstance();
          ????????Connection?conn?
          =?DriverManager.getConnection(url,?username,?password);
          ????????
          try?{
          ??????????ScriptRunner?runner?
          =?new?ScriptRunner(conn,?false,?false);
          ??????????runner.setErrorLogWriter(?
          new?PrintWriter(??System.out?)?);
          ??????????runner.setLogWriter(
          new?PrintWriter(??System.out?));
          ??????????runner.runScript(Resources.getResourceAsReader(
          "hsql/test.sql"));
          ????????}
          catch?(Exception?e)?{
          ????????????e.printStackTrace();
          ????????}?
          finally?{
          ??????????conn.close();
          ????????}
          ??????}
          ??????
          ??????
          ??????String?resource?
          =?"test/persistence/sql-map-config.xml";
          ??????Reader?reader?
          =?Resources.getResourceAsReader?(resource);
          ??????sqlMap?
          =?SqlMapClientBuilder.buildSqlMapClient(reader);
          ????}?
          catch?(Exception?e)?{
          ??????
          throw?new?RuntimeException("Description.??Cause:?"?+?e,?e);
          ????}
          ??}

          ??
          public?static?SqlMapClient?getSqlMap(){
          ??????
          return?sqlMap?;
          ??}

          }


          dao:

          public?class?LevelDao?{
          ?????
          public?static?List<Level>??getAll(){
          ????????
          try?{
          ????????????
          return?DaoConfig.getSqlMap().queryForList("getAllLevel");
          ????????}?
          catch?(Exception?e)?{
          ????????????e.printStackTrace();
          ????????}
          ????????
          return?null?;
          ????}
          }





          持久類說明
          package?test.domain;

          import?java.util.List;

          public?class?Level?{
          ????
          private?Integer?id?;
          ????
          private?String?name?;
          ???
          ??? //得到此對(duì)象父節(jié)點(diǎn) (多對(duì)一)
          ????
          private?Level?flevel?;
          ??? //得到此對(duì)象孩子節(jié)點(diǎn) (一對(duì)多)
          ????private?List<Level>?clevel;


          ????
          public?Integer?getId()?{
          ????????
          return?id;
          ????}

          ????
          public?void?setId(Integer?id)?{
          ????????
          this.id?=?id;
          ????}

          ????
          public?String?getName()?{
          ????????
          return?name;
          ????}

          ????
          public?void?setName(String?name)?{
          ????????
          this.name?=?name;
          ????}



          ????
          public?Level?getFlevel()?{
          ????????
          return?flevel;
          ????}

          ????
          public?void?setFlevel(Level?flevel)?{
          ????????
          this.flevel?=?flevel;
          ????}

          ????
          public?List<Level>?getClevel()?{
          ????????
          return?clevel;
          ????}

          ????
          public?void?setClevel(List<Level>?clevel)?{
          ????????
          this.clevel?=?clevel;
          ????}

          }


          level.xml
          <?xml?version="1.0"?encoding="UTF-8"??>

          <!DOCTYPE?sqlMap?PUBLIC?"-//ibatis.apache.org//DTD?SQL?Map?2.0//EN"
          ????"http://ibatis.apache.org/dtd/sql-map-2.dtd"
          >

          <sqlMap?namespace="level">

          ????
          <typeAlias?alias="level"?type="test.domain.Level"?/>
          ????
          ????
          <resultMap?class="level"?id="getLevelByFa">
          ????????
          <result?property="id"?column="id"?/>??
          ????????
          <result?property="name"?column="name"?/>
          ????????
          <result?property="flevel"?column="fid"?select="level.getLevelId"/>
          ????????
          <result?property="clevel"?column="id"?select="level.getLevelByfId"/>
          ????
          </resultMap>


          ?????
          <select?id="getLevelId"?resultClass="level"?parameterClass="int"?resultMap="getLevelByFa"??>??
          ?????????select?
          ?????????id?,
          ?????????name?,
          ?????????fid?
          ?????????from?level???
          ?????????WHERE?id?=#id#??
          ?????
          </select>
          ????
          ????
          ?????
          <select?id="getLevelByfId"?resultClass="level"?parameterClass="int"?resultMap="getLevelByFa"??>??
          ?????????select?
          ?????????id?,
          ?????????name?,
          ?????????fid?
          ?????????from?level???
          ?????????WHERE?fid?=#id#??
          ?????
          </select>
          </sqlMap>



          map confg
          <?xml?version="1.0"?encoding="UTF-8"??>

          <!DOCTYPE?sqlMapConfig?PUBLIC?"-//ibatis.apache.org//DTD?SQL?Map?Config?2.0//EN"
          ????"http://ibatis.apache.org/dtd/sql-map-config-2.dtd"
          >

          <sqlMapConfig?>?
          ????
          <properties?resource="properties/database.properties"/>
          ????
          <settings?
          ????????
          useStatementNamespaces="true"
          ????
          />??????
          ?
          ?
          ??
          <transactionManager?type="JDBC">
          ????
          <dataSource?type="SIMPLE">
          ??????
          <property?value="${driver}"?name="JDBC.Driver"/>
          ??????
          <property?value="${url}"?name="JDBC.ConnectionURL"/>
          ??????
          <property?value="${username}"?name="JDBC.Username"/>
          ??????
          <property?value="${password}"?name="JDBC.Password"/>
          ????
          </dataSource>
          ??
          </transactionManager>

          ??
          <sqlMap?resource="test/persistence/level.xml"/>


          </sqlMapConfig>







          posted @ 2008-07-14 14:45 G_G 閱讀(4453) | 評(píng)論 (2)編輯 收藏





          html

          <!DOCTYPE?html?PUBLIC?"-//W3C//DTD?HTML?4.01?Transitional//EN"?"http://www.w3.org/TR/html4/loose.dtd">
          <html>
          <head>
          <meta?http-equiv="Content-Type"?content="text/html;?charset=ISO-8859-1">
          <title>Insert?title?here</title>
          </head>
          <body>
          <form?action="">
          ????
          <table>
          ????????
          <tr>
          ????????????
          <td>
          ????????????????
          <select?id="s1"?size="5">
          ????????????????????
          <option>-1-</option>
          ????????????????????
          <option>-2-</option>
          ????????????????????
          <option>-3-</option>
          ????????????????
          </select>
          ????????????
          </td>
          ????????????
          <td>
          ????????????????
          <input?type="button"?value="&gt;&gt;"?onclick="optionRemove('s1','s2');"/>
          ????????????????
          <input?type="button"?value="&lt;&lt;"?onclick="optionRemove('s2','s1');"/>
          ????????????
          </td>
          ????????????
          <td>
          ????????????????
          <select?id="s2"?size="5">
          ????????????????
          </select>
          ????????????
          </td>????????
          ????????
          </tr>
          ????
          </table>
          </form>

          </body>
          <script?type="text/javascript">
          ????
          function?optionRemove(selFromById,selToById){
          ????????
          var?sf?=?document.getElementById(selFromById);
          ????????
          var?st?=?document.getElementById(selToById);
          ????????
          ????????
          var?mo?=??sf.options[sf.selectedIndex];
          ????????
          var?moTest?=??mo.text?;
          ????????
          var?moValue?=?mo.value?;
          ????????
          ????????sf.remove(sf.selectedIndex);?
          ????????st.options.add(
          new?Option(moTest,moValue?),0)

          ????}
          </script>
          </html>


          posted @ 2008-07-12 17:38 G_G 閱讀(208) | 評(píng)論 (0)編輯 收藏

          ?????????? < input? type ="hidden" ?name ="SMSServices" ?value ="" />
          ??????????
          < td >
          ??????????????
          < select? size ="5" ??name ="from_SMSServices" >
          ??????????????????
          <% for ?(SMSService?stmp?:?SMSServiceUtils.getAllSMSService())?{? %>
          ????????????????????
          < option? value ="<%=stmp.getId()%>" > <% = stmp.getName() %> </ option >
          ????????????????
          <% } %>
          ??????????????
          </ select >
          ??????????
          </ td >
          ??????????
          < td >
          ??????????????
          < input? type ="button" ??value ='&#62;&#62;'? onclick ="optionSelectedMove(this.form,'from_SMSServices','to_SMSServices');" />< br />
          ??????????????
          < input? type ="button" ??value ='&#60;&#60;'? onclick ="optionSelectedMove(this.form,'to_SMSServices','from_SMSServices');" />
          ??????????
          </ td >
          ??????????
          < td >
          ??????????????
          < select? size ="5" ?name ="to_SMSServices" >
          ??????????????
          </ select >
          ??????????
          </ td >
          ??????
          </ tr >
          ??????
          ??????
          < tr >< input? type ="button" ?value ="提交" ?onClick ="addSMSServicesValues('SMSServices','to_SMSServices');this.form.submit();" /></ tr >



          javascript 方法
          ????function?addSMSServicesValues(smsName,selectName){
          ????????
          var?obj?=?document.getElementsByName(smsName)[0];
          ????????
          var?selObj?=?document.getElementsByName(selectName)[0];
          ????????obj.value?
          =?'';
          ????????
          ????????
          ????????
          for(var?i=0;i<selObj.options.length;i++)??{??
          ??????????????obj.value?
          +=?selObj.options[i].value+';';
          ??????????}
          ????}
          ????
          function?optionSelectedMove(tform,selfromName,seltoName){

          ????????
          var?selfromObj?=?document.getElementsByName(selfromName)[0];
          ????????
          var?seltoObj?=?document.getElementsByName(seltoName)[0];
          ????????


          ????????
          var?optmp?=?null?;
          ????????
          for(var?i=0;i<selfromObj.options.length;i++)??{??
          ??????????????
          if(selfromObj.options[i].selected==true)??{??
          ??????????????????optmp?
          =?selfromObj.options[i];
          ??????????????????selfromObj.remove(i);
          ??????????????????
          break;
          ??????????????}??
          ??????????}

          ??????????
          ??????????
          //var?varItem?=?new?Option(objItemText,?objItemValue);?????
          ????????seltoObj.options.add(optmp);

          ????}

          posted @ 2008-07-04 11:03 G_G 閱讀(632) | 評(píng)論 (0)編輯 收藏

          此文隨時(shí)更新

          項(xiàng)目svn http://mycompetence.googlecode.com/svn/trunk/mycompetence/
          如在瀏覽器中查看有亂碼問題。
          請(qǐng)把瀏覽器編碼改成 utf-8 或 gb2312 查看試試;


          數(shù)據(jù)表結(jié)構(gòu)create.sql(未完)
          項(xiàng)目說明 項(xiàng)目說明.txt(未完)


          在一片聲討中,項(xiàng)目以蝸牛的速度慢慢開始了。
          2008-6-25 嘗試持久層建模; create.sql

          2008-6-30 16:46 添加配置工具類,并確立簡(jiǎn)單的配置插件使用
          ???????????????????? (參考:dataSource.DataSourceUtil)



          posted @ 2008-06-26 12:03 G_G 閱讀(1394) | 評(píng)論 (0)編輯 收藏

          項(xiàng)目下載地址
          http://www.aygfsteel.com/Files/Good-Game/TurtleSwims2.rar

          此系統(tǒng)為?ssh?框架

          svn?:
          cd?E:\svnProject
          e:
          start?svnserve?
          -d?-r?.?

          1.spring?管理hibernate事務(wù)

          2.spring?管理struts2注入

          3.ant?demo?中hibernate對(duì)類文件下的使用
          ????可在ant?中找到?
          <!--?hibernate?需要維護(hù)的?fileset?-->
          ????
          <fileset?dir="demo">
          ????????
          <include?name="**/*Bean.java"?/>
          ????
          </fileset>
          ????生成映射
          ????
          4.ant?hbm2ddl??
          ????
          0.建立此動(dòng)作文件????????????????????????????????????????????????????
          ????
          1.備份數(shù)據(jù)庫(kù),并重建數(shù)據(jù)庫(kù)?????
          ????
          2.建立hbm2ddl標(biāo)簽并建create?table?sql?文件
          ????
          3.執(zhí)行sql文件????????

          5.ant?test?
          ????可在ant?中找到
          <!--?junit?需要維護(hù)的?fileset?-->
          ?????對(duì)類文件為?Test
          *.class
          ?????.
          /conf/htmlreport/junit-noframes.html????????


          6.web?table?展現(xiàn)?可以使用?eXtremeComponents
          ????http:
          //127.0.0.1:8080/TurtleSwims/demo/extremecomponents.jsp

          7.在線文本編輯器
          ????
          /TurtleSwims/demo/fckeditor.jsp
          ????commons
          -fileupload.jar
          ????FCKeditor
          -2.3-modify.jar

          8.文件上傳
          ????fileUploadDemo.action
          ????
          /demo/strtus2/fileUploadDemo.jsp

          9.圖片生成
          ????
          /demo/pictureYield.action
          ????

          posted @ 2008-06-23 17:06 G_G 閱讀(2265) | 評(píng)論 (3)編輯 收藏

               摘要: 功能描述: 1.ant hibernate:由class xdoclet 得到映射.2.hbm2ddl? action???2.0.建立此動(dòng)作文件??????????????????????????????????????????????????? ???2.1.備份數(shù)據(jù)庫(kù),并重建數(shù)據(jù)庫(kù)???? ???2.2.建立hbm2ddl標(biāo)簽并建create table sql 文件???...  閱讀全文

          posted @ 2008-06-23 16:27 G_G 閱讀(1723) | 評(píng)論 (0)編輯 收藏

          大家有什么好意見盡量跟我說。我盡量把這編文章弄得更適應(yīng)大家開發(fā)。方便大家使用
          ???此文時(shí)時(shí)更新

          1.每張表除有關(guān)業(yè)務(wù)描述列外最好預(yù)留:
          • ??? IsShow(true/false) 一些關(guān)鍵數(shù)據(jù)刪除采用隱藏.
          • ??? version(long|int) 樂觀鎖使用 hibernate 問題_3(鎖
          • ??? 預(yù)留擴(kuò)展字段 (可以參考:google protobuf 等)
          ???


          2.關(guān)聯(lián)關(guān)系映射注意21. 示例:父子關(guān)系(Parent Child Relationships)
          • ??? 添加級(jí)聯(lián)孩子對(duì)象,會(huì)生成兩條sql(INSERTc創(chuàng)建, UPDATEpc的連接p)。
          ??? ??? ??? ??? 解決辦法:<set name="children" inverse="true">
          ??? ?? ?? ?? ?? 參考:21.2. 雙向的一對(duì)多關(guān)系(Bidirectional one-to-many)
          • ??? 刪除級(jí)聯(lián)孩子對(duì)象,級(jí)聯(lián)刪除.
          ??? ?? ?? ?? ?? 解決辦法1:<set name="children" inverse="true" cascade="all-delete-orphan">
          ??? ?? ?? ?? ?? 參考:21.3. 級(jí)聯(lián)生命周期(Cascading lifecycle)
          ??? ?? ?? ?? ?? 解決辦法2:刪除隱藏策略
          ??? ?? ?? ???
          <set name="children" inverse="true" where=" IsShow=boolean|int " cascade="save-update">
          ??? ?? ?? ?? ? 許多數(shù)據(jù)庫(kù)沒有boolean類型可以用 整型替代 數(shù)據(jù)建立默認(rèn)0可見,不可見改為1.


          3一般表設(shè)計(jì)

          posted @ 2008-06-16 15:35 G_G 閱讀(2858) | 評(píng)論 (1)編輯 收藏

          google svn 服務(wù)器使用:
          ??? 1. http://code.google.com/ 用gmail登入。>后點(diǎn)擊>Project Hosting
          ??? 2. 進(jìn)入>> http://code.google.com/hosting/? >后點(diǎn)擊>Create a new project
          ??? 3. 填入必要的項(xiàng)目名,描述等確定。就可以了
          ??? 4. 確定成功后 ->Source
          ??? 5. 到eclipse的打開新建一個(gè)project->team->share Project->svn
          ??? 6. 后面根據(jù) google source 上的svn提示,這我就不多說了。一般的svn http url


          ?


          posted @ 2008-06-10 15:18 G_G 閱讀(14265) | 評(píng)論 (1)編輯 收藏

          僅列出標(biāo)題
          共16頁(yè): 上一頁(yè) 1 2 3 4 5 6 7 8 9 下一頁(yè) Last 
          主站蜘蛛池模板: 凉城县| 奇台县| 富平县| 自治县| 樟树市| 安陆市| 垫江县| 永顺县| 南阳市| 剑河县| 芦溪县| 奉化市| 奇台县| 肥城市| 丰台区| 汨罗市| 新余市| 万山特区| 遂昌县| 长武县| 海淀区| 丽水市| 英山县| 海口市| 浮梁县| 纳雍县| 金沙县| 乐都县| 毕节市| 额敏县| 神木县| 富川| 志丹县| 崇信县| 平果县| 宜城市| 延寿县| 通河县| 英吉沙县| 连平县| 淮安市|