To make it easier to set database connections and transaction consistency, set all database connection information in the fcconfig. xml file;
Fcconfig. XML content:
<? XML version = "1.0" encoding = "UTF-8"?>
<Root>
<Datasources>
<DS name = "fhjtest" dbtype = "sqlserver"
Type = "JDBC" jdbcdriver = "com. newAtlanta. jturbo. driver. driver "jdbcurl =" JDBC: jturbo: // localhost/eformtest/charset = GBK "user =" sa "Password =" "/>
<DS name = "ebsql" dbtype = "sqlserver"
Type = "JDBC" jdbcdriver = "com. newAtlanta. jturbo. driver. driver "jdbcurl =" JDBC: jturbo: // localhost/ebtest/charset = GBK "user =" sa "Password =" "/>
<DS name = "eformsql" dbtype = "sqlserver"
Type = "JDBC" jdbcdriver = "com. newAtlanta. jturbo. driver. driver "jdbcurl =" JDBC: jturbo: // localhost/eformtest/charset = GBK "user =" sa "Password =" "/>
<DS name = "eboracle" dbtype = "oracle"
Type = "JDBC" jdbcdriver = "oracle. JDBC. driver. oracledriver "jdbcurl =" JDBC: oracle: thin: @ localhost: 1521: SYS "user =" eboracle "Password =" eboracle "/>
<DS name = "eformoracle" dbtype = "oracle"
Type = "JDBC" jdbcdriver = "oracle. JDBC. driver. oracledriver "jdbcurl =" JDBC: oracle: thin: @ localhost: 1521: SYS "user =" eformtest "Password =" eformtest "/>
</Datasources>
<Fileroot>/ebsys </fileroot>
<Pubparam> User. ID, user. Name, department. ID, department. Name, system. unit name </pubparam>
</Root>
Multiple Data Source connections can be set in the <datasources> </datasources> node.
E table, eform, or Workflow SystemThe first <DS> connection string is used by default.
The advantages of this setting are as follows:
1. By modifying this file, you can separate the development library, Test Library, and running official library. For example, you can use a set of libraries for development and test, set the connection to the JNDI database during the formal operation;
2. You can use multiple data sources in the same system. For example, if you specify the data source name in an operation request, you can use the specified data source without specifying the default data source, achieve a set of systems using multiple data sources.
CodeImplementation process:
Read the configuration information of the fcconfig. xml file at a time;
It can be read once in singleton mode;
You can also read it at a time through the servlet Init ().(This method is used in the workflow );
When you need to establish a database connection, you can establish a database connection based on the input CENAME;If CENAME is not input, the first one is obtained;
Database Transaction consistency settings:
The custom module of the Business System in the workflow system eworkflow is implemented using the eform, and the process is progressive with a separate workflow engine;
When a process instance is running, the business data must be stored and the process must be kept in one transaction. That is, when a commit fails, the business data and process are rolled back;
This requires that the submission of the eform and the progressive persistence of the workflow instance in the same transaction:
Implementation process:
Set an environment. Java class separately:
This class is responsible for calling connectionconfig. Java to create a database connection. Each time a Conn is obtained, the transaction is started. And provides the commit and close methods and transaction rollback methods;
Before the process instance is submitted in a step-by-step manner, an environment instance is created to transfer the environment instance to the eform engine and workflow eworkflow engine. When a database connection is required, obtain one from the Environment instance and start the transaction. if an exception is thrown, the Environment instance is called for rollback;
After business data is saved and the process is saved, call the environment instance to close the submission; submit data and close the database connection.
In this way, the process data is consistent with the business data.
Related links;
Workflow concept in Web Workflow Management System Development
Web workflow management system development 2 workflow engine
Web workflow management system development 3 visualization process designer
Custom forms for Web Workflow Management System Development
Development of Web workflow management system 5 open source osworkflow-user system transformation
Six-form permission and process permission Control for Web Workflow Management System Development
8. Open-source osworkflow Task Management in Web Workflow Management System Development
Ten database connections and transaction settings for Web Workflow Management System Development
Interaction between process data and business data during Web Workflow Management System Development
Twelve permission controls for transferring a single form to multiple nodes in a process developed by the Web workflow management system
13 process integration with electronic forms in Web Workflow Management System Development
14 Implementation of the Process designer attribute page in Web Workflow Management System Development