Derby GRANT statement using for give privileges to a specific user
<p>I have created Database with <code>sqlAuthorization</code> and some Tables in <code>Derby</code>. When i add some <code>fullAccessUsers</code> to system, users can't reach to tables because privileges. I use <code>GRANT</code> statement for users but don't help. I share my code below;</p>

<p><strong>Creating DB;</strong></p>

<pre><code>String owner = "admin";
String ownerp = "admin";
String user1= "testuser";
String user1p = "testuser";
String driver = "org.apache.derby.jdbc.ClientDriver";
String connectionURL = "jdbc:derby://10.90.232.2:1527/myDB"+";user="+"\""+owner+"\""+";create=true";
Connection conn = DriverManager.getConnection(connectionURL);
</code></pre>

<p><strong>Setting DB Properties;</strong></p>

<pre><code>Class.forName(driver);
connectionURL = "jdbc:derby://10.90.232.2:1527/myDB"+";create=false;user="+"\""+owner+"\""+";password="+"\""+ownerp+"\""+";";
conn = DriverManager.getConnection(connectionURL);
Statement s = conn.createStatement();

//Setting DB to Require Authentication
s.executeUpdate("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(" +
                "'derby.connection.requireAuthentication', 'true')");

//Setting DB to SQL Authorization                           
s.executeUpdate("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(" +
                "'derby.database.sqlAuthorization', 'true')");

//Setting DB to SQL Authorization                         
s.executeUpdate("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(" +
                "'derby.authentication.provider', 'BUILTIN')");

//Creating owner username and password
s.executeUpdate("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(" +
                "'derby.user."+"\""+owner+"\""+"', '"+"\""+ownerp+"\""+"')");

//Creating testuser username and password
s.executeUpdate("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(" +
                "'derby.user."+"\""+user1+"\""+"', '"+"\""+user1p+"\""+"')");

//Set both owner and user as a fullAccessUsers (read/write)
s.executeUpdate("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(" +
                "'derby.database.fullAccessUsers', '"+"\""+owner+"\""+","+"\""+user1+"\""+"')");

//Setting DB to No Access for restrict unauthorized users
s.executeUpdate("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(" +
                "'derby.database.defaultConnectionMode', 'noAccess')");

s.executeUpdate("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(" +
                "'derby.database.propertiesOnly', 'false')");
s.close();

//This method shutdown the derby for take parameters.
shutDownDerby();
</code></pre>

<p><strong>Creating Table;</strong></p>

<pre><code>//This method start the Derby Network Server
startDerby();

String connectionUrl2 = "jdbc:derby://10.90.232.2:1527/myDB"+";user="+"\""+owner+"\""+";password="+"\""+ownerp+"\""+";"; 
Connection con2 = DriverManager.getConnection(connectionUrl2);
java.sql.Statement stmt2;
stmt2 = con2.createStatement();

//Creating Schema
stmt2.execute("CREATE SCHEMA TEST");

//Creating Table in TEST Schema
String query1 = "CREATE TABLE TEST.USER_INFO\n" +
                "(\n" +
                "USERNAME VARCHAR(80),\n" +
                "INFO VARCHAR(160)\n" +
                ")";

stmt2.execute(query1);

//This one should GRANT permission for reach TEST.USER_INFO to testuser but NOT!
stmt2.execute("GRANT SELECT ON TABLE TEST.USER_INFO TO testuser");
</code></pre>

<p>I succesfully connect to DB with <code>testuser</code>. But when i try Select from <code>TEST.USER_INFO</code> with <code>testuser</code> i receive below <code>SQLException</code>;</p>

<p><strong>Select Query;</strong></p>

<pre><code>String query = "SELECT USERNAME, INFO FROM TEST.USER_INFO";
</code></pre>

<p><strong>SQLException;</strong></p>

<pre><code>ERROR 42502: User 'testuser' does not have SELECT permission on column 'USERNAME' of table 'TEST'.'USER_INFO'.
</code></pre>

<p>If i connect to DB with DB Owner, Select statement return <code>resultset</code> succesfully. What am i missing in <code>GRANT</code> Statement i don't understand.</p>