posts - 37,  comments - 53,  trackbacks - 0
ofbiz默认的数据库为derby,这个当然不能在生产环境中使用,而且也不方便调试和管理。虽然ofbiz也支持很多的开源数据库,例如mysql等,但是我们这里还是使用主流的数据库系统oracle 11g.详细的操作如下
1.更新JDBC驱动,将oracle最新的jdbc驱动copy到${ofbiz install dir}/framework/entity/lib/jdbc 目录下。
2.设置实体引擎( Entity Engine)的缺省数据库为oracle.在修改 ${ofbiz install dir}/framework/entity/config/entityengine.xml文件中修改配置:
   a.修改数据库连接参数:
     <datasource name="localoracle"
            helper-class="org.ofbiz.entity.datasource.GenericHelperDAO"
            schema-name="ofbiz" 你的数据库schema名称
            field-type-name="oracle"
            check-on-start="true"
            add-missing-on-start="true"
            alias-view-columns="false"
            join-style="ansi">
        <read-data reader-name="seed"/>
        <read-data reader-name="seed-initial"/>
        <read-data reader-name="demo"/>
        <read-data reader-name="ext"/>
        <inline-jdbc
                jdbc-driver="oracle.jdbc.driver.OracleDriver"
                jdbc-uri="jdbc:oracle:thin:@192.168.1.154:1521:ofbiz"  ofbiz为你的数据库SID
                jdbc-username="ofbiz"  用户名
                jdbc-password="ofbiz"  密码
                pool-minsize="2"
                pool-maxsize="250"/>
    </datasource>
  b. 修改实体引擎的数据库缺省配置如下:(将datasource-name的值设置为“localoracle”)
      <delegator name="default" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main" distributed-cache-clear-enabled="false">
        <group-map group-name="org.ofbiz" datasource-name="localoracle"/>
        <group-map group-name="org.ofbiz.olap" datasource-name="localoracle"/>
    </delegator>
    <delegator name="default-no-eca" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main" entity-eca-enabled="false" distributed-cache-clear-enabled="false">
        <group-map group-name="org.ofbiz" datasource-name="localoracle"/>
        <group-map group-name="org.ofbiz.olap" datasource-name="localoracle"/>
    </delegator>

    <!-- be sure that your default delegator (or the one you use) uses the same datasource for test. You must run "ant run-install" before running "ant run-tests" -->
    <delegator name="test" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main">
        <group-map group-name="org.ofbiz" datasource-name="localoracle"/>
        <group-map group-name="org.ofbiz.olap" datasource-name="localoracle"/>
    </delegator>
    <delegator name="other" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main">
        <group-map group-name="org.ofbiz" datasource-name="localoracle"/>
    </delegator>
3.补充:在进行以上配置时,请确保你已经存在ofbiz的数据库,实例,用户等都已创建好。
4. 初始化数据和导入:   
     ofbiz$ java -jar ofbiz.jar -install
通过以上命令即可进行数据库的初始化和初始数据的导入,这里包括了ofbiz自带的例子,应用的所有的数据表和初始化数据

5.问题:
在使用oracle数据库时,当前的版本可能会碰到ORA-01843:无效的月份的问题      

    以sys用户登陆并创建Trigger:

    create or replace TRIGGER ON_CONNECT AFTER LOGON ON DATABASE
     DECLARE
     guser varchar2(30);
     begin
      SELECT sys_context('USERENV','SESSION_USER') into guser FROM dual;
         if (guser='ofbiz' or guser='OFBIZ') THEN
            EXECUTE IMMEDIATE 'alter session set nls_timestamp_format = ''YYYY-MM-DD HH24:MI:SS.FF''';
         end if;
     end;

注意对登陆用户名的判断必须大小写都要考虑.

另:ofbiz用户不能拥有dba的权限,同时ofbiz用户比需要有UNLIMITED TABLESPACE的权限,否则在创建数据表的时候会报“数据库空间不足”的错误,导致无法创建表。

6.参考:
http://blog.csdn.net/blieveme/archive/2007/10/16/1826604.aspx
http://docs.ofbiz.org/display/~jacopoc/OFBiz+and+Oracle

今天就到这里吧,明天继续:) 
posted on 2009-09-03 20:27 雪地孤鸿 阅读(2595) 评论(3)  编辑  收藏 所属分类: ofbiz学习

FeedBack:
# re: ofbiz9 + oracle 11g
2009-09-03 22:08 | 翔子
学习了 ~ blog很不错  回复  更多评论
  
# re: ofbiz9 + oracle 11g
2009-09-04 14:38 | 99读书人
不错哦3213  回复  更多评论
  
# re: ofbiz9 + oracle 11g
2009-09-06 19:10 | 移动彩铃12530
死杜甫时间跨度福建撒娇的看法都是  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航:
 
<2009年9月>
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

常用链接

留言簿(17)

随笔分类

随笔档案

文章档案

blog

搜索

  •  

最新评论

阅读排行榜

评论排行榜