Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 17 » UltraLite - Database Management and Developer Guide » UltraLite database schemas » UltraLite users

SQL statements for managing UltraLite users

You can use the CREATE USER, ALTER USER, and DROP USER statements to manage users in an UltraLite database.

Note

As an alternative to SQL statements, you can use the following UltraLite API methods in your application to grant or revoke user access to an UltraLite database:

  • ULConnection.GrantConnectTo method [UltraLite C++]
  • ULConnection.RevokeConnectFrom method [UltraLite C++]
  • ULGrantConnectTo method [UltraLite Embedded SQL]
  • ULRevokeConnectFrom method [UltraLite Embedded SQL]
  • ULConnection.GrantConnectTo method [UltraLite.NET]
  • ULConnection.RevokeConnectFrom method [UltraLite.NET]

Grant and revoke methods are not available in the UltraLiteJ API. For Android devices, construct a CREATE USER, ALTER USER, or DROP USER statement as a string variable and pass it to the Connection.prepareStatement method.

Example

The following example illustrates how to use the UltraLiteJ API connect to an existing UltraLite database, and use the CREATE USER statement to create a new user:

ConfigFile config = 
    DatabaseManager.createConfigurationFileAndroid("DBname.udb", getApplicationContext());
Connection conn = DatabaseManager.connect(config);

String sql_string = "CREATE USER test-user IDENTIFIED BY test-password";
PreparedStatement authenticator = conn.prepareStatement(sql_string);
authenticator.execute();
authenticator.close();