经过数次实验,openfire终于可以调用已有的数据库用户表了。
1 安装openFire。
? 在安装过程中我使用的是SqlServer数据库,首先在数据库中建了一个库openfire。一开始始终链接不上,后来搜索说是用sqljdbc4.jar来驱动,于是下载下来,果然可以。

但是后来我有又使用了默认的jdbc驱动程序类,发现也是可以的,可能是当时把用户名、密码写错了。
等到链接上以后执行到最后登录控制台,查看openfire数据库就可以看到有好的数据表,其实我们要关心主要是这几个表ofProperty、ofUser。
然后参照篇文章做了http://www.cnblogs.com/2018/archive/2011/12/13/2279869.html相应处理。建立另外一个库(这个库就是我们要链接的自己用户表)
然后在openfire数据库中执行
insert into ofproperty(name,propValue)values ('jdbcProvider.driver','net.sourceforge.jtds.jdbc.Driver'), ('jdbcProvider.connectionString','jdbc:jtds:sqlserver://192.168.1.21/openfire;appName=openfire;user=of;password=00'),68); font-family:Arial; font-size:14px; line-height:26px">('admin.authorizedJIDs','admin@127.0.0.1'),68); font-family:Arial; font-size:14px; line-height:26px">('jdbcAuthProvider.passwordSQL','SELECT plainPassword FROM myUser WHERE username=?'),68); font-family:Arial; font-size:14px; line-height:26px">('jdbcAuthProvider.passwordType','plain'),68); font-family:Arial; font-size:14px; line-height:26px">('jdbcUserProvider.loadUserSQL',242)">SELECT name,email FROM myUser WHERE username=?'),68); font-family:Arial; font-size:14px; line-height:26px">('jdbcUserProvider.userCountSQL',242)">SELECT COUNT(*) FROM myUser'),68); font-family:Arial; font-size:14px; line-height:26px">('jdbcUserProvider.allUsersSQL',242)">SELECT username FROM myUser'),68); font-family:Arial; font-size:14px; line-height:26px">('jdbcUserProvider.usernameField','username'),68); font-family:Arial; font-size:14px; line-height:26px">('jdbcUserProvider.nameField','name'),68); font-family:Arial; font-size:14px; line-height:26px">('jdbcUserProvider.emailField','email');
UPDATE ofProperty SET propValue='org.jivesoftware.openfire.user.JDBCUserProvider' WHERE? name='provider.user.className'; UPDATE ofProperty SET propValue='org.jivesoftware.openfire.auth.JDBCAuthProvider' WHERE? name='provider.auth.className';
这里主意('admin.authorizedJIDs',@后的值就是xmpp.domain对应的值
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|