http://www.docjar.com/html/api/org/apache/catalina/realm/JDBCRealm.java.html
To use this JDBCRealm we need two tables, user and user_role.
user table - user_id, user_name, user_password
user_role table - user_id, role_id, user_name
Why user_name is required in user_role table when user_id is there as foreign key. The JDBCRealm could have used a join query to extract roles or a direct query as well if it stores the user_id from the previous query.