PL/SQL (MOSC)

MOSC Banner

ORA-01001: invalid cursor

edited Mar 17, 2020 5:00AM in PL/SQL (MOSC) 1 commentAnswered

using oracle below document but not working plsql and java code.

How to Return a JDBC ResultSet as a REF CURSOR From a Java Stored Procedure (Doc ID 150448.1)

------------------------------------------

[oracle@xxxxxx1] xxxxxxx]$ cat sqlExecution.java

import java.sql.*;

import oracle.jdbc.*;

import java.util.Properties;

import oracle.jdbc.pool.OracleDataSource;

public class sqlExecution  {

        public static ResultSet selectSqlExecution(String dbServiceName, String mySql)

        {

                                ResultSet rset = null;

                try

                {

                Connection dbConn = makeConnection(dbServiceName);

                                ((OracleConnection)dbConn).setCreateStatementAsRefCursor(true);

                Statement stmt = dbConn.createStatement();

                rset = stmt.executeQuery (mySql);

                }

                catch(Exception e)

                {

                        System.out.println(e.getMessage());

                }

                                return rset;

        }

                public static Connection makeConnection (String dbServiceName) throws Exception

                        {

                                        Class.forName ("oracle.jdbc.driver.OracleDriver");

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center