我正在使用DataSourceRealm
以下代码:
Context initContext = new InitialContext();
DataSourceRealm dss = new DataSourceRealm();
DataSourceRealm ds = (DataSourceRealm) initContext.lookup("java:/comp/env/InfoFeedProxyDataBase");
// i'm getting connot cast DataSource to DataSourceRealm
这是我在tomcat中的配置:
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<ResourceLink type="javax.sql.DataSource"
name="InfoFeedProxyDataBase"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/ppe3-1"
username="root"
password="" />
<Realm className="org.apache.catalina.realm.DataSourceRealm"
dataSourceName="InfoFeedProxyDataBase"
localDataSource="true"
digest="MD5"
roleNameCol="role"
userCredCol="password"
userNameCol="login"
userRoleTable="roles"
userTable="users" />
我试过这段代码:
DataSourceRealm dsr = new DataSourceRealm();
dsr.start();
我是否知道如何在Java中使用DataSourceRealm
对象?