Be sure to define the database name in your authentication queries.
Even though one may (and should) define a single database to be accessed
for each connection pool, it seems one needs to explicitly refer to the
same database in a Shiro environment. Otherwise you'll get
java.sql.SQLException: No database selected

I'll leave a working example:
ds = org.apache.shiro.jndi.JndiObjectFactory
ds.resourceName = jdbc/myauthds
 
 ## the actual authentication realm
 jdbcRealm = org.apache.shiro.realm.jdbc.JdbcRealm
 jdbcRealm.permissionsLookupEnabled = true
jdbcRealm.authenticationQuery = SELECT password FROM myauthdb.USERS
WHERE username = ? AND active = 1
jdbcRealm.userRolesQuery = SELECT role_name FROM myauthdb.USERS_ROLES
WHERE username = ?
jdbcRealm.permissionsQuery = SELECT permission_name FROM
myauthdb.ROLES_PERMISSIONS WHERE role_name = ?

P.S.: I also have an "active" field which enables me to "automagically"
invalidate authentication requests from "inactive" users, even though
they've provided correct credentials.

Cheers,

-- 
Paulo Pires

Reply via email to