6.9.1.4 Using the oracle.pg.rdbms.pgql Java Package to Execute PGQL Queries
The Java API in the oracle.pg.rdbms.pgql
package provides support for executing PGQL queries against Oracle Database. This topic explains how to use the Java API through a series of examples.
Note:
Effective with Release 21c, the following classes in the oracle.pg.rdbms
package are deprecated:
oracle.pg.rdbms.OraclePgqlColumnDescriptorImpl oracle.pg.rdbms.OraclePgqlColumnDescriptor oracle.pg.rdbms.OraclePgqlExecutionFactory oracle.pg.rdbms.OraclePgqlExecution oracle.pg.rdbms.PgqlPreparedStatement oracle.pg.rdbms.OraclePgqlResultElementImpl oracle.pg.rdbms.OraclePgqlResultElement oracle.pg.rdbms.OraclePgqlResultImpl oracle.pg.rdbms.OraclePgqlResultIterable oracle.pg.rdbms.OraclePgqlResultIteratorImpl oracle.pg.rdbms.OraclePgqlResult oracle.pg.rdbms.OraclePgqlResultSetImpl oracle.pg.rdbms.OraclePgqlResultSet oracle.pg.rdbms.OraclePgqlResultSetMetaDataImpl oracle.pg.rdbms.OraclePgqlResultSetMetaData oracle.pg.rdbms.PgqlSqlQueryTransImpl oracle.pg.rdbms.PgqlSqlQueryTrans oracle.pg.rdbms.PgqlStatement
You should instead use equivalent classes in oracle.pg.rdbms.pgql
:
oracle.pg.rdbms.pgql.PgqlColumnDescriptorImpl oracle.pg.rdbms.pgql.PgqlColumnDescriptor oracle.pg.rdbms.pgql.PgqlConnection oracle.pg.rdbms.pgql.PgqlExecution oracle.pg.rdbms.pgql.PgqlPreparedStatement oracle.pg.rdbms.pgql.PgqlResultElementImpl oracle.pg.rdbms.pgql.PgqlResultElement oracle.pg.rdbms.pgql.PgqlResultSetImpl oracle.pg.rdbms.pgql.PgqlResultSet oracle.pg.rdbms.pgql.PgqlResultSetMetaDataImpl oracle.pg.rdbms.pgql.PgqlSqlTransImpl oracle.pg.rdbms.pgql.PgqlSqlTrans oracle.pg.rdbms.pgql.PgqlStatement
One difference between oracle.pg.rdbms.OraclePgqlResultSet
and oracle.pg.rdbms.pgql.PgqlResultSet
is that oracle.pg.rdbms.pgql.PgqlResultSet does not provide APIs to retrieve vertex and edge objects. Existing code using those interfaces should be changed to project IDs rather than OracleVertex
and OracleEdge
objects. You can obtain an OracleVertex
or OracleEdge
object from the projected ID values by calling OracleVertex.getInstance()
or OracleEdge.getInstance()
. (For an example, see Example 6-21.)
See Oracle Graph Property Graph Java APIs for more details on setting the classpath for compiling and executing your Java applications.
The following test_graph
data set in Oracle flat file format will be used in the examples in subtopics that follow. The data set includes a vertex file (test_graph.opv
) and an edge file (test_graph.ope
).
test_graph.opv
:
2,fname,1,Ray,,,person 2,lname,1,Green,,,person 2,mval,5,,,1985-01-01T12:00:00.000Z,person 2,age,2,,41,,person 0,bval,6,Y,,,person 0,fname,1,Bill,,,person 0,lname,1,Brown,,,person 0,mval,1,y,,,person 0,age,2,,40,,person 1,bval,6,Y,,,person 1,fname,1,John,,,person 1,lname,1,Black,,,person 1,mval,2,,27,,person 1,age,2,,30,,person 3,bval,6,N,,,person 3,fname,1,Susan,,,person 3,lname,1,Blue,,,person 3,mval,6,N,,,person 3,age,2,,35,,person
test_graph.ope
:
4,0,1,knows,mval,1,Y,, 4,0,1,knows,firstMetIn,1,MI,, 4,0,1,knows,since,5,,,1990-01-01T12:00:00.000Z 16,0,1,friendOf,strength,2,,6, 7,1,0,knows,mval,5,,,2003-01-01T12:00:00.000Z 7,1,0,knows,firstMetIn,1,GA,, 7,1,0,knows,since,5,,,2000-01-01T12:00:00.000Z 17,1,0,friendOf,strength,2,,7, 9,1,3,knows,mval,6,N,, 9,1,3,knows,firstMetIn,1,SC,, 9,1,3,knows,since,5,,,2005-01-01T12:00:00.000Z 10,2,0,knows,mval,1,N,, 10,2,0,knows,firstMetIn,1,TX,, 10,2,0,knows,since,5,,,1997-01-01T12:00:00.000Z 12,2,3,knows,mval,3,,342.5, 12,2,3,knows,firstMetIn,1,TX,, 12,2,3,knows,since,5,,,2011-01-01T12:00:00.000Z 19,2,3,friendOf,strength,2,,4, 14,3,1,knows,mval,1,a,, 14,3,1,knows,firstMetIn,1,CA,, 14,3,1,knows,since,5,,,2010-01-01T12:00:00.000Z 15,3,2,knows,mval,1,z,, 15,3,2,knows,firstMetIn,1,CA,, 15,3,2,knows,since,5,,,2004-01-01T12:00:00.000Z 5,0,2,knows,mval,2,,23, 5,0,2,knows,firstMetIn,1,OH,, 5,0,2,knows,since,5,,,2002-01-01T12:00:00.000Z 6,0,3,knows,mval,3,,159.7, 6,0,3,knows,firstMetIn,1,IN,, 6,0,3,knows,since,5,,,1994-01-01T12:00:00.000Z 8,1,2,knows,mval,6,Y,, 8,1,2,knows,firstMetIn,1,FL,, 8,1,2,knows,since,5,,,1999-01-01T12:00:00.000Z 18,1,3,friendOf,strength,2,,5, 11,2,1,knows,mval,2,,1001, 11,2,1,knows,firstMetIn,1,OK,, 11,2,1,knows,since,5,,,2003-01-01T12:00:00.000Z 13,3,0,knows,mval,5,,,2001-01-01T12:00:00.000Z 13,3,0,knows,firstMetIn,1,CA,, 13,3,0,knows,since,5,,,2006-01-01T12:00:00.000Z 20,3,1,friendOf,strength,2,,3,
- Basic Query Execution
- Executing PGQL Queries Using JDBC Driver
- Security Techniques for PGQL Queries
- Using a Text Index with PGQL Queries
- Obtaining the SQL Translation for a PGQL Query
- Additional Options for PGQL Translation and Execution
- Querying Another User’s Property Graph
- Using Query Optimizer Hints with PGQL
- Modifying Property Graphs through INSERT, UPDATE, and DELETE Statements