The JDBC driver can process PL stored procedures and anonymous blocks. It supports the PL block syntax and JDBC escape syntax.
The following PL calls can be used together with the JDBC driver:
// The JDBC escape syntax.
CallableStatement ecs1 = conn.prepareCall
( "{call proc (?,?)}" ) ; // A stored procedure.
CallableStatement ecs2 = conn.prepareCall
( "{? = call func (?,?)}" ) ; // A stored function.
// The PL block syntax.
CallableStatement ecs3 = conn.prepareCall
( "begin proc (?,?); end;" ) ; // A stored procedure.
CallableStatement ecs4 = conn.prepareCall
( "begin ? := func(?,?); end;" ) ; // A stored function.
Function calls in the JDBC program:
OceanBaseDataSource obds = new OceanBaseDataSource();
obds.setURL("jdbc:oceanbase:oracle://connection string:1521/username");
obds.setUser("Adam");
obds.setPassword("P@ssw0rd");
Connection conn = obds.getConnection();
CallableStatement cs = conn.prepareCall ("begin ? := f(?); end;");
cs.registerOutParameter(1,Types.CHAR);
cs.setString(3, "aaa");
cs.executeUpdate();
String result = cs.getString(1);
Example: Calling a PL function to retrieve a character sequence and add a suffix to it
CREATE OR REPLACE FUNCTION f (v CHAR)
RETURN CHAR AS
BEGIN
RETURN v || 'suffix';
END;