JDBC gateway

Read(362) Label: jdbc gateway, sql, gateway property,

When calling an esProc script via JDBC, we can create a SQL gateway by configuring a dfx script file, and let it handle all the SQL statements to be executed in JDBC. The gateway script reads in the SQL statements and their parameters, handles database connection, and then executes SQL and returns results. Below is a gateway script executeSQL.dfx:








if args==null || args.len()<2







return B1

The dfx file uses two parameters:

The above two parameters are necessary. The first passes the SQL statements that have been input at the call of the esProc script. The second passes parameters input for executing the SQL statements.

To use the JDBC gateway, we need to specify the gateway script file in <gateway> under raqsoftConfig.xml’s <JDBC> node. To connect a data source, load the data source connection configuration from Runtime or Server:






With required configuration done, all the SQL statements will be handed over to the gateway script for execution during the invocation of esProc JDBC from Java. For example:

// Execute SQL; the question mark (?) represents the parameter

st =con.prepareCall("select * from CITIES where STATEID = ? and POPULATION > ?");

// Set parameters

st.setObject(1, 5);

st.setObject(2, 400000);

// Execute the stored procedure


// Get the result set

ResultSet rs1 = st.getResultSet();

// Directly execute SQL with no input parameters

ResultSet rs2 = con.createStatement().executeQuery("select STATEID,NAME,ABBR,CAPITAL from STATES where STATEID<8");

Since the gateway script has checked the status of the non-input parameters, it can execute SQL with no input parameters. Below are the outputs of the query results rs1 and rs2:

The connection to and disconnection from a data source are handled by the gateway script. With a default data source, we can directly use its name in executing a query and there is no need to handle data source disconnection.