JDBC Program (from E-Commerce book)
Java.sql.CallableStatement stmt;
Connection conn;
ResultSet res;
//Setup Connection
conn = DriverManager.getConnection("jdbc:default");
//prepare statement to execute
stmt = conn.prepareStatment("SELECT empno, ename FROM emp WHERE
sal > ? and deptno = ? ");
//Use positional parameters to set variables
stmt.setString(1,sal_p);
stmt.setInteger(2, deptno_p);
//Execute query and store results
res = stmt.executeQuery();
|
Equivalent SQLJ Program (from E-Commerce
book)
ResultSet res;
#sql res = (SELECT empno, ename FROM emp WHERE sal > :sal_p
AND deptno = :deptno_p);
//pass the above throug the SQLJ translator and will
// get the same results as program on the left.
|