ofbiz 使用 oracle 开发遇到的一些问题
转自 http://ajava.org/course/open/14640.html
转自 http://job6688.spaces.live.com/blog/cns!FA3F6195E8CF95F7!236.entry
ofbiz默认的数据库为derby,这个当然不能在生产环境中使用,而且也不方便调试和管理。虽然ofbiz也支持很多的开源数据库,例如mysql等,但是我们这里还是使用主流的数据库系统oracle 11g.详细的操作如下
1.更新JDBC驱动,将oracle最新的jdbc驱动copy到${ofbizinstalldir}/framework/entity/lib/jdbc目录下。
2.设置实体引擎(EntityEngine)的缺省数据库为oracle.在修改${ofbizinstalldir}/framework/entity/config/entityengine.xml文件中修改配置:
a.修改数据库连接参数:<datasource name="localoracle"
helper-class="org.ofbiz.entity.datasource.GenericHelperDAO"
schema-name="OFBIZ"
field-type-name="oracle"
check-on-start="true"
add-missing-on-start="true"
join-style="ansi">
<read-data reader-name="seed"/>
<read-data reader-name="demo"/>
<read-data reader-name="ext"/>
<inline-jdbc
jdbc-driver="oracle.jdbc.driver.OracleDriver"
jdbc-uri="jdbc:oracle:thin:@10.1.9.233:1521:mydb"
jdbc-username="ofbiz"
jdbc-password="ofbiz"
pool-minsize="2"
pool-maxsize="10"/>
</datasource>2.修改framework\entity\config目录下面的entityengine.xml
由默认的localhsql修改为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.odbc" datasource-name="localoracledd"/>
</delegator>3.问题:在使用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;4.运行 java -jar ofbiz.jar -install
5.启动startofbiz.bat即可。
说明: 移植到mysql 更简单。mysql的驱动已经有了,只需要修改数据源信息即可。更详尽的请查阅
https://cwiki.apache.org/confluence/display/OFBIZ/OFBiz+and+Oracle