Query JD Edwards Data in ColdFusion
The CData JDBC driver for JD Edwards seamlessly integrates connectivity to JD Edwards data with the rapid development tools in ColdFusion. This article shows how to connect to JD Edwards data in ColdFusion and query JD Edwards tables.
Create a JDBC Data Source for JD Edwards in ColdFusion
The JDBC data source enables you to execute SQL from standard ColdFusion tags like cfquery and CFScript like executeQuery.
-
Copy the driver JAR and .lic file from the installation directory onto the ColdFusion classpath. For example, copy the files into C:\MyColdFusionDirectory\cfusion\wwwroot\WEB-INF\lib. Or, open the Java and JVM page in the ColdFusion Administrator and enter the path to the files in the ColdFusion Class Path box.
The JAR and license for the driver are located in the lib subfolder of the installation directory.
Restart the server after this step.
-
Add the driver as a data source:
From the ColdFusion administrator interface, expand the Data & Services node and click Data Sources. In the Add New Data Source section, enter a name for the data source and select Other in the Driver menu.
-
Populate the driver properties:
JDBC URL: Enter connection properties in the JDBC URL. The JDBC URL begins with jdbc:jdedwards: and is followed by the connection properties in a semicolon-separated list of name=value pairs.
The driver connects to JD Edwards through your Application Interface Services (AIS) Server. Set the following connection properties:
- URL: The base HTTPS URL of your AIS Server (e.g., https://jde-ais.example.com:8300).
- User: Your JD Edwards username.
- Password: Your JD Edwards password.
- Environment (optional): The JD Edwards environment to use (e.g., PD920 for production or DV920 for development). If not specified, the AIS Server's default environment is used.
- Role (optional): The JD Edwards role for the session. If not specified, the AIS Server's default role is used.
- DeviceName (optional): An identifier for the connecting device or application, used for auditing and logging on the AIS Server.
- Jasserver (optional): The specific Java Application Server (JAS) instance to route requests through, useful in clustered environments.
Choosing Which Data Is Exposed
JD Edwards organizes tables and business views by System Code, and the driver exposes each System Code as its own schema. Use these properties to control which schemas are available:
- DataModel: One or more ERP modules (comma-separated) whose System Codes are exposed as schemas, or All to expose every System Code in the connected instance. Defaults to FinancialManagement.
- SystemCodes: A comma-separated list of additional System Codes to expose alongside those from DataModel (e.g., 42,43).
When you connect, the driver sends your credentials to the AIS Server to obtain a session token and caches it. The driver requests a new token automatically before the session expires.
Built-in Connection String Designer
For assistance in constructing the JDBC URL, use the connection string designer built into the JD Edwards JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.
java -jar cdata.jdbc.jdedwards.jarFill in the connection properties and copy the connection string to the clipboard.
A typical JDBC URL is below:
jdbc:jdedwards:URL=https://your-jde-environment-app.example.com;User=admin;Password=myPassword;- Driver Class: Enter the driver class. The driver class is cdata.jdbc.jdedwards.JDEdwardsDriver.
- Driver Name: Enter a user-defined name for the driver.
- Username: Enter the username used to authenticate.
- Password: Enter the password used to authenticate.
You can now test the connection by enabling the CData JD Edwards data source in the Actions column. After reporting a status of OK, the JD Edwards data source is ready for use.
Execute Queries
The cfquery tag can pass SQL statements to JD Edwards. Use the cfqueryparam tag to create parameterized queries and prevent SQL injection through the query string.
Note: To use the cfquery and cfscript, create a .cfm file. Inside the .cfm file, write the code to execute the query (see below). Place the file directly in the root directory of your web server (e.g., wwwroot in Adobe ColdFusion). Restart the service after placing the file for the changes to take effect.
<cfquery name="JDEdwardsQuery" dataSource="CDataJDEdwards">
SELECT * FROM AccountsPayable.AccountLedger WHERE BusinessUnit = <cfqueryparam value="#BusinessUnit#" cfsqltype="cf_sql_varchar">
</cfquery>
<cfdump var="#JDEdwardsQuery#">
Below is the equivalent in CFScript:
<cfscript>
result = queryExecute(
"SELECT * FROM AccountsPayable.AccountLedger WHERE BusinessUnit = ?",
[
{ value="100", cfsqltype="cf_sql_varchar" }
],
{ datasource="CDataJDEdwards" }
);
writeDump( var= result );
</cfscript>
You can then make requests to your .cfm like the following:
http://MyServer:8500/query.cfm?BusinessUnit=100