Enterprise edition JDBC

Read(489) Label: enterprise edition, jdbc,

The features explained in this section only supported in esProc Enterprise edition. Users using another esProc edition just skip this section.

Here we introduce how to deploy and use esProc Enterprise edition JDBC. Besides the ordinary esProc JDBC (called PJDBC), we have Enterprise edition JDBC (called QJDBC) in esProc Enterprise edition. The two JDBCs are basically same except that they use different esProc related jars. PJDBC uses ordinary esProc related jars while QJDBC needs Enterprise edition related jars. Same as deploying and configuring the PJDBC, you should deploy the raqsoftConfig.xml file to complete QJDBC deployment and, if you want to integrate esProc in a project, you should configure web.xml file in the project.

Deploying and configuring Enterprise edition JDBC

If you already install the esProc Enterprise edition, you can find the complete QVS project, which is the esProc Enterprise edition multipurpose server, in esProc installation directory. The specific location is [installation directory]\esProc\esProc\q-server. In [installation directory]\esProc\esProc\q-server\lib directory, there are esProc Enterprise edition server and the basic jars QJDBC needs; esproc-ent-xxxx.jar, which is unique to the esProc Enterprise edition, must be included. If you want to use the extended functionalities, such as database connection, in QJDBC, you should add the corresponding jars. You can find descriptions of different jars in Deploying JDBC.

Besides the above mentioned xml file, [installation directory]\esProc\config\raqsoftConfig.xml is also used for deploying the QJDBC. The file can be found in q-server\webapps\qvs\WEB-INF\home. The two configuration files have similar content, but the latter is used for server loading and will not adjust itself when the esProc edition changes. You need to edit it yourself as needed.

Read Scudata Cloud Deployment to find more about esProc Enterprise edition server.

Using Enterprise edition JDBC

Use QJDBC in the same way as you use PJDBC, such as invoking call statement in Java to execute SPL statement and calling a cellset file. You can use functions unique to the Enterprise edition to perform the operation. Take the following cellset file testQJDBC.splx as an example:

 

A

1

=dql("pseudo/test.glmd")

2

=A1.query("select EID, Name, ifMarried from emps")

3

=A2.i()

4

>output(ifpure(A3))

5

return A3

The cellset file uses some functions unique to esProc Enterprise edition. A1 uses dql() function to open a DQL definition file; A2 executes a query statement in DQL; A3 uses P.i() function to convert the result to a pure table sequence where all fields have same data type. To check if the conversion is successful, A4 uses ifpure() function to judge whether it is a pure table sequence or not and output the result.

Use the following Java code to invoke the Enterprise edition JDBC to execute the cellset file. Here we specify configuration file as raqsoftConfig.xml; use the default file if no configuration file is specified:

public void testDataServer(){

Connection con = null;

java.sql.PreparedStatement st;

try{

// Establish connection

Class.forName("com.esproc.jdbc.InternalDriver");

con= DriverManager.getConnection("jdbc:esproc:local://?config=D:/soft/raqsoft/esProc/q-server/webapps/qvs/WEB-INF/home/raqsoftConfig.xml");

// Invoke the stored procedure; createTable1 is the script file name

st =con.prepareCall("call testQJDBC()");

// Execute stored procedure

st.execute();

// Get result set

ResultSet rs = st.getResultSet();

 

// Process result set simply: output field names and data

ResultSetMetaData rsmd = rs.getMetaData();

int colCount = rsmd.getColumnCount();

for ( int c = 1; c <= colCount;c++) {

String title = rsmd.getColumnName(c);

if ( c > 1 ) {

System.out.print("\t");

}

else {

System.out.print("\n");

}

System.out.print(title);

}

while (rs.next()) {

for (int c = 1; c<= colCount; c++) {

if ( c > 1 ) {

System.out.print("\t");

}

else {

System.out.print("\n");

}

Object o = rs.getObject(c);

System.out.print(o.toString());

}

}

}

catch(Exception e){

System.out.println(e);

}

finally{

// Close connection

if (con!=null) {

try {

con.close();

}

catch(Exception e) {

System.out.println(e);

}

}

}

}

The syntax is the same as invoking the ordinary esProc JDBC. Here we use "call testQJDBC()" to execute the SPL file and result is as follows:

Note that dql(), P.i() and ifpure() functions used in this cellset file cannot be used for ordinary esProc JDBC.

Read DQL Tool to find more about esProc Enterprise edition DQL.