On 11/16/17 2:34 PM, AlbertoLopez wrote:
I created a database, and need to convert it to NATIVE authentication.
Derby's Developer's Manual states I need to create an user in order to
conver it. I tried to do that and get a "procedure not recognized"
exception.

I viewed the SYSCS_UTIL folder, through NetBeans service and I can see some
procedures put the CREATE_USER in not there and I don´t know if it should be
there or there is another problem.

The code is simple :

  statement.executeUpdate("call SYSCS_UTIL.SYSCS_CREATE_USER( 'app', 'app'
)";

And the exception I get is:


java.sql.SQLSyntaxErrorException: 'SYSCS_UTIL.SYSCS_CREATE_USER' no se
reconoce como una función o procedimiento.
        at 
org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown
Source)
        at org.apache.derby.client.am.SqlException.getSQLException(Unknown 
Source)
        at org.apache.derby.client.am.Statement.executeUpdate(Unknown Source)
        at Database.main(Database.java:141)
Caused by: org.apache.derby.client.am.SqlException:
'SYSCS_UTIL.SYSCS_CREATE_USER' no se reconoce como una función o
procedimiento.
        at org.apache.derby.client.am.Statement.completeSqlca(Unknown Source)
        at 
org.apache.derby.client.net.NetStatementReply.parsePrepareError(Unknown
Source)
        at
org.apache.derby.client.net.NetStatementReply.parsePRPSQLSTTreply(Unknown
Source)
        at org.apache.derby.client.net.NetStatementReply.readPrepare(Unknown
Source)
        at org.apache.derby.client.net.StatementReply.readPrepare(Unknown 
Source)
        at org.apache.derby.client.net.NetStatement.readPrepare_(Unknown Source)
        at org.apache.derby.client.am.Statement.readPrepare(Unknown Source)
        at org.apache.derby.client.am.Statement.flowExecute(Unknown Source)
        at org.apache.derby.client.am.Statement.executeUpdateX(Unknown Source)



--
Sent from: 
http://apache-database.10148.n7.nabble.com/Apache-Derby-Developers-f4.html

Hi Alberto,

Can you try the following program? It produces the following expected output for me:

Database 'memory:db' shutdown.
Correctly failed to connect without credentials: Connection authentication failure occurred.  Reason: Invalid authentication..
Successfully connected as user APP.

import java.sql.*;

public class CreateNativeUser
{
  public static void main(String... args) throws Exception
  {
    {
      Connection conn = DriverManager.getConnection("jdbc:derby:memory:db;create=true");       conn.prepareCall("call SYSCS_UTIL.SYSCS_CREATE_USER('app', 'app')").execute();
    }

    // verify that user was created. bounce the database and re-connect
    try
    {
DriverManager.getConnection("jdbc:derby:memory:db;shutdown=true");
    }
    catch (SQLException se) { println(se.getMessage()); }

    // should fail because no credentials are provided
    try
    {
      Connection conn = DriverManager.getConnection("jdbc:derby:memory:db");       println("Hm, should not have been able to connect without credentials.");
    }
    catch (SQLException se)
    { println("Correctly failed to connect without credentials: " + se.getMessage()); }

    // now connect with correct credentials
    try
    {
      Connection conn = DriverManager.getConnection("jdbc:derby:memory:db;user=app;password=app");
      println("Successfully connected as user APP.");
    }
    catch (SQLException se)
    { println("Did not expect to fail authentication: " + se.getMessage()); }
  }

  private static void println(String text) { System.out.println(text); }
}

Reply via email to