JBPM5.4连接Mysql数据库

使用JBPM5.4官网的完全安装包 连接mysql数据库。

一、安装JBPM5.4

到jboss官网下载JBPM5.4官网的完全安装包 jbpm-5.4.0.Final-installer-full.zip并解压。安装前请先安装ant工具 http://ant.apache.org/bindownload.cgi 

找到JBPM5.4安装包的根目录,通过cmd命令找到 E:\ZiLiao\api-jar\jbpm\jbpm-5.4.0.Final-installer-full\jbpm-installer。

输入ant安装命令 ant install.demo 进行安装,此过程必须联网,安装过程会

l 下载JBoss AS

l 下载Eclipse

l 安装Drools Guvnor into JBoss AS

l 安装Oryx Designer into JBoss AS

l 安装the jBPM gwt-console intoJBoss AS

l 安装the jBPM Eclipse plugin

l 安装the Drools Eclipse plugin

如果计算机中已有Jboss服务器并设置JBOSS_HOME环境变量请删除,否则会影响Jboss安装。

提示安装成功后,可以进行测试安装结果:

分别输入 ant start.h2 (启动h2数据库);ant start.jboss;

如果安装成功 则在浏览器中输入http://localhost:8080/jbpm-console/app.html 可以进入JBPM控制台;


二、连接mysql 

转自:http://blog.csdn.net/haiyan2012/article/details/8881021

关闭jboss服务器 输入ant stop.jboss

然后在安装包中进行文件替换

需要修改的文件为:

  • build.properties
  • build.xml
  • db/jbpm-persistence-JPA2.xml
  • db/task-persistence-JPA2.xml
  • standalone.xml
  • task-service/resources/META-INF/persistence.xml
  • lib/jbpm-gwt-console-server-5.4.0.Final-EE6.war/WEB-INF/classes/META-INF/persistence.xml
  • lib/jbpm-human-task-war-5.4.0.Final-EE6.war/WEB-INF/classes/META-INF/persistence.xml


  • 1.下载MySql驱动放在安装目录/db/drivers/下。这里将名字修改为mysql-connector-java.jar。

  • 在MySql数据库中创建task和jbpm数据库。

    [html]  view plain copy
    1. mysql> CREATE DATEBASE IF NOT EXISTS jbpm5;  
    2. mysql> CREATE USER 'jbmp5'@'localhost' IDENTIFIED BY 'jbpm5';  
    3. mysql> GRANT ALL PRIVILEGES ON jbpm5.* TO 'jbpm5'@'localhost';  
    [html]  view plain copy
    1. mysql> CREATE DATEBASE IF NOT EXISTS task;  
    2. mysql> CREATE USER 'task'@'localhost' IDENTIFIED BY 'task';  
    3. mysql> GRANT ALL PRIVILEGES ON task.* TO <a href="mailto:'task'@'localhost;">'task'@'localhost;  
    4. </a>  

    2.修改db/jbpm-persistence-JPA2.xml和task-persistence-JPA2.xml,修改方式类似

    Xml代码
    [xml]  view plain copy
    1. 将  
    2. <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />  
    3. 或  
    4. <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>  
    5. 修改为  
    6. <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />  

    附:

    Hibernate SQL Dialects (hibernate.dialect)

    RDBMS Dialect
    DB2org.hibernate.dialect.DB2Dialect
    DB2 AS/400org.hibernate.dialect.DB2400Dialect
    DB2 OS390org.hibernate.dialect.DB2390Dialect
    PostgreSQLorg.hibernate.dialect.PostgreSQLDialect
    MySQL

    org.hibernate.dialect.MySQLDialect

    org.hibernate.dialect.MySQL5Dialect

    MySQL with InnoDBorg.hibernate.dialect.MySQLInnoDBDialect
    MySQL with MyISAMorg.hibernate.dialect.MySQLMyISAMDialect
    Oracle (any version)org.hibernate.dialect.OracleDialect
    Oracle 9iorg.hibernate.dialect.Oracle9iDialect
    Oracle 10gorg.hibernate.dialect.Oracle10gDialect
    Sybaseorg.hibernate.dialect.SybaseDialect
    Sybase Anywhereorg.hibernate.dialect.SybaseAnywhereDialect
    Microsoft SQL Serverorg.hibernate.dialect.SQLServerDialect
    SAP DBorg.hibernate.dialect.SAPDBDialect
    Informixorg.hibernate.dialect.InformixDialect
    HypersonicSQLorg.hibernate.dialect.HSQLDialect
    Ingresorg.hibernate.dialect.IngresDialect
    Progressorg.hibernate.dialect.ProgressDialect
    Mckoi SQLorg.hibernate.dialect.MckoiDialect
    Interbaseorg.hibernate.dialect.InterbaseDialect
    Pointbaseorg.hibernate.dialect.PointbaseDialect
    FrontBaseorg.hibernate.dialect.FrontbaseDialect
    Firebirdorg.hibernate.dialect.FirebirdDialect

    3.修改task-service/resources/META-INF/persistence.xml
    Xml代码
    [xml]  view plain copy
    1. 将  
    2. <properties>  
    3.       <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>  
    4.       <property name="hibernate.connection.driver_class" value="org.h2.Driver"/>  
    5.       <property name="hibernate.connection.url" value="jdbc:h2:tcp://localhost/runtime/task" />  
    6.       <property name="hibernate.connection.username" value="sa"/>  
    7.       <property name="hibernate.connection.password" value=""/>  
    8.       <property name="hibernate.connection.autocommit" value="false" />  
    9.       <property name="hibernate.max_fetch_depth" value="3"/>  
    10.       <property name="hibernate.hbm2ddl.auto" value="create" />  
    11.       <property name="hibernate.show_sql" value="false" />  
    12.     </properties>  
    13. 修改为  
    14. <properties>  
    15.       <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>  
    16.       <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>  
    17.       <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/task" />  
    18.       <property name="hibernate.connection.username" value="task"/>  
    19.       <property name="hibernate.connection.password" value="task"/>  
    20.       <property name="hibernate.connection.autocommit" value="false" />  
    21.       <property name="hibernate.max_fetch_depth" value="3"/>  
    22.       <property name="hibernate.hbm2ddl.auto" value="create" />  
    23.       <property name="hibernate.show_sql" value="false" />  
    24.     </properties>  

    4.修改db/mysql_module.xml中jar的名称为mysql.jar,与db/drivers中的jar名称对应。

    Xml代码
    [xml]  view plain copy
    1. <resources>  
    2.      <resource-root path="mysql-connector-java.jar"/>  
    3. </resources>  

    5.使用的是Jboss7,修改安装目录下的standalone.xml
    Xml代码
    [xml]  view plain copy
    1. 将  
    2. <subsystem xmlns="urn:jboss:domain:datasources:1.0">  
    3.             <datasources>  
    4.                 <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">  
    5.                     <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>  
    6.                     <driver>h2</driver>  
    7.                     <security>  
    8.                         <user-name>sa</user-name>  
    9.                         <password>sa</password>  
    10.                     </security>  
    11.                 </datasource>  
    12.                 <datasource jta="true" jndi-name="java:jboss/datasources/jbpmDS" pool-name="H2DS" enabled="true" use-java-context="true" use-ccm="true">  
    13.                     <connection-url>jdbc:h2:~/jbpm</connection-url>  
    14.                     <driver>h2</driver>  
    15.                     <pool>  
    16.                         <min-pool-size>1</min-pool-size>  
    17.                         <max-pool-size>4</max-pool-size>  
    18.                         <prefill>false</prefill>  
    19.                         <use-strict-min>false</use-strict-min>  
    20.                         <flush-strategy>FailingConnectionOnly</flush-strategy>  
    21.                     </pool>  
    22.                     <security>  
    23.                         <user-name>sa</user-name>  
    24.                     </security>  
    25.                     <validation>  
    26.                         <check-valid-connection-sql>SELECT 1</check-valid-connection-sql>  
    27.                         <validate-on-match>false</validate-on-match>  
    28.                         <background-validation>false</background-validation>  
    29.                     </validation>  
    30.                 </datasource>  
    31.                 <drivers>  
    32.                     <driver name="h2" module="com.h2database.h2">  
    33.                         <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>  
    34.                     </driver>  
    35.                 </drivers>  
    36.             </datasources>  
    37.         </subsystem>  
    38. 修改为  
    39. <subsystem xmlns="urn:jboss:domain:datasources:1.0">  
    40.             <datasources>  
    41.                 <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">  
    42.                     <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>  
    43.                     <driver>h2</driver>  
    44.                     <security>  
    45.                         <user-name>sa</user-name>  
    46.                         <password>sa</password>  
    47.                     </security>  
    48.                 </datasource>  
    49.                 <datasource jta="true" jndi-name="java:jboss/datasources/jbpmDS" pool-name="H2DS" enabled="true" use-java-context="true" use-ccm="true">  
    50.                     <connection-url>jdbc:mysql://localhost:3306/jbpm5</connection-url>  
    51.                     <driver>mysql</driver>  
    52.                     <pool>  
    53.                         <min-pool-size>1</min-pool-size>  
    54.                         <max-pool-size>4</max-pool-size>  
    55.                         <prefill>false</prefill>  
    56.                         <use-strict-min>false</use-strict-min>  
    57.                         <flush-strategy>FailingConnectionOnly</flush-strategy>  
    58.                     </pool>  
    59.                     <security>  
    60.                         <user-name>jbpm5</user-name>  
    61.             <password>jbpm5</password>  
    62.                     </security>  
    63.                     <validation>  
    64.                         <check-valid-connection-sql>SELECT 1</check-valid-connection-sql>  
    65.                         <validate-on-match>false</validate-on-match>  
    66.                         <background-validation>false</background-validation>  
    67.                     </validation>  
    68.                 </datasource>  
    69.                 <drivers>  
    70.                     <driver name="mysql" module="com.mysql">  
    71.                         <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>  
    72.                     </driver>  
    73.                 </drivers>  
    74.             </datasources>  
    75.         </subsystem>  
    6.修改安装目录下的build.properties,将数据库的配置从H2,改为MySql
    [xml]  view plain copy
    1. # default is H2  
    2. #db.name=h2  
    3. #db.driver.jar.name=${db.name}.jar  
    4. #db.driver.download.url=http://repo1.maven.org/maven2/com/h2database/h2/${H2.version}/h2-${H2.version}.jar  
    5. #other options are mysql  
    6.   db.name=mysql  
    7.   db.driver.module.prefix=com/mysql  
    8.   db.driver.jar.name=${db.name}.jar  
    9.   db.driver.download.url=https://repository.jboss.org/nexus/service/local/repositories/central/content/mysql/mysql-connector-java/5.1.18/mysql-connector-java-5.1.18.jar  
    7.修改/lib/jbpm-human-task-war-5.4.0.Final-EE6.war/WEB-INF/classes/META-INF/persistence.xml文件中的 hibernate.dialect
    Xml代码
    [xml]  view plain copy
    1. <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>  
    8.修改/lib/jbpm-gwt-console-server-5.4.0.Final-EE6.war/ WEB-INF/classes/META-INF/persistence.xml 文件中的 hibernate.dialect和 hibernate.hbm2ddl.auto。
    Xml代码
    [xml]  view plain copy
    1. <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />  
    2.   
    3. <property name="hibernate.hbm2ddl.auto" value="create" />  
    9.修改build.xml
    Xml代码
    [xml]  view plain copy
    1. 在  
    2.  <java classname="org.jbpm.DemoTaskService" fork="true">    
    3.       <classpath>  
    4.         <pathelement path="${install.home}/task-service/target"/>  
    5.         <path refid="classpath.human.task" />  
    6.       </classpath>  
    7.     </java>  
    8.   
    9. 中加  
    10. <sysproperty key="jbpm.user.group.mapping" value="file:///F:/PDF/jbpm/jbpm-installer/jboss-as-7.1.1.Final/standalone/configuration/roles.properties"/>   
    11. 变为  
    12.  <java classname="org.jbpm.DemoTaskService" fork="true">    
    13.       <sysproperty key="jbpm.user.group.mapping" value="file:///F:/PDF/jbpm/jbpm-installer/jboss-as-7.1.1.Final/standalone/configuration/roles.properties"/>   
    14.       <classpath>  
    15.         <pathelement path="${install.home}/task-service/target"/>  
    16.         <path refid="classpath.human.task" />  
    17.       </classpath>  
    18.     </java>  
    19. 根据你的实际目录修改  
     
    [html]  view plain copy
    1. <!-- Start Demo -->  
    2. <target name="start.demo" depends="start.h2,start.jboss,start.eclipse" />  
    3.   
    4. <!-- Start Demo (Eclipse) -->  
    5. <target name="start.demo.eclipse" depends="start.h2,start.eclipse" />  
    6.   
    7. <!-- Start Demo (No Eclipse)-->  
    8. <target name="start.demo.noeclipse" depends="start.h2,start.jboss" />  
    9.   
    10. <!-- Stop Demo -->  
    11. <target name="stop.demo" depends="stop.h2,stop.jboss" />  

    中加
    [html]  view plain copy
    1. <!-- Start Demo -->  
    2. <target name="start.demo" depends="start.h2,start.jboss,start.eclipse" />  
    3.   
    4. <!-- Start Demo (DB) -->  
    5. <target name="start.demo.db" depends="start.jboss, start.eclipse" />  
    6.   
    7. <!-- Start Demo (DB, No Eclipse) -->  
    8. <target name="start.demo.db.noeclipse" depends="start.jboss" />  
    9.   
    10. <!-- Start Demo (Eclipse) -->  
    11. <target name="start.demo.eclipse" depends="start.h2,start.eclipse" />  
    12.   
    13. <!-- Start Demo (No Eclipse)-->  
    14. <target name="start.demo.noeclipse" depends="start.h2,start.jboss" />  
    15.   
    16. <!-- Stop Demo -->  
    17. <target name="stop.demo" depends="stop.h2,stop.jboss" />  
    18.   
    19. <!-- Stop Demo (DB)-->  
    20. <target name="stop.demo.db" depends="stop.jboss" />  
    10.在CMD中到你的安装目录下,运行
    Java代码
    [java]  view plain copy
    1. ant install.demo  
    2. 或  
    3. ant install.demo.noeclipse  
    11.运行
    Java代码
    [java]  view plain copy
    1. ant start.human.task  
    创建task数据库表 ,创建完成后按Ctrl+C,再按退出创建。
    12.运行
    Java代码
    [java]  view plain copy
    1. ant start.jboss  
    启动,会创建jbpm数据库表。
    启动成功后再运行
    Java代码
    [java]  view plain copy
    1. ant stop.jboss  
    成功关闭后修改安装目录下\jboss-as-7.1.1.Final\standalone\deployments\jbpm-gwt-console-server.war\ WEB-INF/classes/META-INF/persistence.xml 文件中的 hibernate.hbm2ddl.auto。
    Xml代码
    1. <propertyname="hibernate.hbm2ddl.auto"value="update"/>






评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值