半山云嵐

             :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            10 隨筆 :: 0 文章 :: 1 評論 :: 0 Trackbacks

          用了 Derby 數據庫好一段時間了,雁過留痕。

          作為內存數據庫或嵌入式數據庫,Derby 是一個很好的選擇,完全由 Java 實現,在 JDK1.6 中 Derby 已經作為其一部分來發布了,稱之為 JavaDB。

          Derby 數據庫通過 derby.properties 文件來配置,這個文件需要放在程序的 classpath 或者 jdk 的 javadb classpath 路徑中。下面是一些配置的例子:

          ---------------------------- Derby derby.properties information ----------------------------
          --### Derby System Home Directory
          derby.system.home=D:/workspace/Boulevard/BoulevardDB


          --### Derby Authentication Configuration and Turn On
          derby.connection.requireAuthentication=true
          derby.authentication.provider=BUILTIN
          derby.database.propertiesOnly=true
          --### User/Password Definition (System Level)
          derby.user.alfred=alfred
          --### User Authorization Definition (System Level)
          derby.database.defaultAccessMode=fullAccess
          derby.fullAccessUsers=cube


          --### Some Others Configuration
          derby.infolog.append=true
          derby.storage.pageSize=4096
          derby.storage.pageReservedSpace=60
          derby.locks.deadlockTimeout=20
          derby.locks.waitTimeout=30
          ---------------------------- Derby derby.properties information ----------------------------


          Derby 數據庫可以啟動為兩種不同的模式:嵌入式模式服務器模式

          1. 嵌入式模式(embedded):當 Java 應用程序第一次嘗試連接數據庫時啟動數據庫實例,當程序進程結束時數據庫實例也被關閉。當數據庫實例啟動后,僅僅啟動它的進程可以訪問,其它任何外部進程(運行在當前進程的JVM之外的程序)都不能訪問。

              下面的命令用于啟動并連接一個嵌入式數據庫實例:
          ------------------------------- Derby connection information -------------------------------
          -- ### Use ij command to connect embeded database; if not exist, create it.
          CONNECT 'jdbc:derby:data;create=true;user=alfred;password=alfred' AS CUBE;
          -- ### Use ij command to connect embeded database; if not exist, don't create it, throw out error.
          CONNECT 'jdbc:derby:data;user=alfred;password=alfred' AS CUBE;
          ------------------------------- Derby connection information -------------------------------

          2. 服務器模式(network server):數據庫實例只能由命令行啟動:"...\javadb\bin\startNetworkServer.bat",該實例始終有效,直到通過命令行停止:"...\javadb\bin\stopNetworkServer.bat"。任何運行在本地或遠程的JVM進程都可以訪問,不會隨著訪問它的程序的結束而關閉。

              下面的命令用于連接(不能啟動)服務器數據庫實例:
          ------------------------------- Derby connection information -------------------------------
          -- ### Use ij command to connect network server database, reading default repository;
          -- ### If not exist, create it.
          CONNECT 'jdbc:derby://localhost:1527/data;create=true;user=alfred;password=alfred' AS BOULEVARD;
          -- ### Use ij command to connect network server database; reading default repository;
          -- ### If not exist, don't create it, throw out error.
          CONNECT 'jdbc:derby://localhost:1527/data;user=alfred;password=alfred' AS BOULEVARD;
          -- ### Use ij command to connect network server database, reading specific repository;
          -- ### If not exist, create it.
          CONNECT 'jdbc:derby://localhost:1527/D:/workspace/Boulevard/BoulevardDB/data;create=true;user=alfred;password=alfred' AS BOULEVARD;
          -- ### Use ij command to connect network server database, reading specific repository;
          -- ### If not exist, don't create it, throw out error.
          CONNECT 'jdbc:derby://localhost:1527/D:/workspace/Boulevard/BoulevardDB/data;user=alfred;password=alfred' AS BOULEVARD;
          ------------------------------- Derby connection information -------------------------------

          posted on 2010-01-06 17:44 Alfred. Yao 閱讀(2025) 評論(0)  編輯  收藏 所屬分類: 數據庫

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


          網站導航:
           
          主站蜘蛛池模板: 乌苏市| 施秉县| 崇信县| 忻城县| 西昌市| 磴口县| 平江县| 马关县| 绵竹市| 泰宁县| 蕲春县| 合江县| 庄浪县| 犍为县| 改则县| 盐源县| 越西县| 珠海市| 长岛县| 清徐县| 三河市| 红桥区| 会理县| 苍山县| 齐河县| 吉木乃县| 武威市| 习水县| 永和县| 陕西省| 阳西县| 桓仁| 渑池县| 乌兰察布市| 临猗县| 南澳县| 曲靖市| 庄浪县| 宝鸡市| 房产| 崇文区|