$(db)sql;…

Read(151) Label: data source, sql, result set,

Description:

Through esProc JDBC, execute the specified SQL statement in the database and return the result set.

Syntax:

$(db)sql;

Note:

In the specified database db, the function executes the specified SQL statement, and returns the result set once executed. Use st.executeQuery() for the execution and return the result set. Make sure the database db must be connected. If there are parameters in the statement, they always start with arg.

In JDBC, a string starting with select or with will be interpreted as a simple SQL statement for execution. If the string is followed by a pair of parentheses, it will be interpreted as a dfx file name. For instance, selectTab() represents a dfx file name.

Parameters:

sql

A SQL statement, like select * from table; it should be any of the select/insert/delete/update statements

(db)

Datasource name

SQL parameter’s value

Return value:

A set

Example:

public void testDataServer() {

  Connection con = null;

  java.sql.Statement st;

  try{

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

  con= DriverManager.getConnection("jdbc:esproc:local://"); 

  st=con.createStatement();

  // Query demo database student table to find the data of students who are older than 16

  ResultSet set = st.executeQuery("$(demo)select * from STUDENTS where AGE>?;16");

  printRs(set);

  }

  catch(Exception e){

  System.out.println(e);

  }

  finally{

  // Close the connection

  if (con!=null) {

  try {

  con.close();

  }

  catch(Exception e) {

  System.out.println(e);

  }

  }

  }

  }