Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2002
    Posts
    4

    Unanswered: Java stored procedure privileges

    Hello,

    I have created a Java stored procedure that executes a select and update
    statement in the procedure owner schema. It works all fine when client
    program connects as owner schema to execute the procedure, but it fails in
    select statement when I try it connecting using a different schema. The
    procedure begins execution but ceases at select. Documentation says Grant
    has no effect in such procedures, what can I do?

    My environment is DB2 6.1 for AIX.

    Than you so much.

    Here are the CREATE PROCEDURE statement and Java stored procedure code (it
    works when Java client connects using SCHEMA1, but not using SCHEMA2):

    CREATE PROCEDURE SCHEMA1.testProc (IN column char(2),OUT result
    varchar(1000)) LANGUAGE JAVA MODIFIES SQL DATA PARAMETER STYLE JAVA NOT
    FENCED EXTERNAL NAME 'TestProc.testGrant'


    public static void testGrant(String column, String[] result) throws
    java.sql.SQLException {

    String dn = null;
    String uid = null;
    Connection con = null;
    try {
    con = DriverManager.getConnection("jdbc:default:connecti on");
    ResultSet rs = null;
    Statement stmt = con.createStatement();
    rs = stmt.executeQuery("SELECT " + column +" FROM SCHEMA1.testP");

    int numReg = 0;
    int numMax = 0;
    int iNum = 0;
    int iMax = 0;
    while (rs.next()) {
    iNum = (int)rs.getInt(1);
    iNum++;
    }
    stmt.close();

    stmt = con.createStatement();
    stmt.executeUpdate("UPDATE SCHEMA1.testP SET A = " + iNum);
    stmt.close();
    con.commit();
    result[0]= "OK";

    con.close();


    return;

    }
    catch (Exception e)
    {
    result[0]="Error: "+e.getMessage();
    }
    finally {
    try {
    con.close();
    }
    catch (Exception e2) {
    }
    return;
    }
    }

  2. #2
    Join Date
    Aug 2002
    Posts
    35
    You need one more SQL modify to M(means fopr insert/update/delete SQL).
    vasu

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •