openfire整合已有用户数据库(在logs里出现问题:

本文讨论了OpenFire与MySQL数据库集成过程中遇到的问题,包括配置错误导致的集成失败,以及通过直接修改数据库表来正确实现集成的方法。提供了解决方案并分享了测试数据库结构和内容,以及如何有效进行集成的代码示例。
摘要由CSDN通过智能技术生成

Property 'jdbcProvider.connectionString' as specified in openfire.xml differs from what is stored in the database. Please make property changes in the database instead of openfire.xml.)http://lishao378.blog.sohu.com/146785554.html

 

首先看下测试数据库结构和内容:

mysql> use test;
Database changed
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| user           |
+----------------+
1 row in set (0.00 sec)

mysql> select * from user;
+-----+-------+----------------------------------+-----------------+
| uid | uname | upass                            | email           |
+-----+-------+----------------------------------+-----------------+
|   1 | admin | admin                            | admin@localhost |
|   2 | test  | 5c177f35077e9e0a4a5f7cb4dbc96937 | test@localhost  |
+-----+-------+----------------------------------+-----------------+
2 rows in set (0.00 sec)

其中:admin密码是明文,test密码是字符串phpcms经md5加密后的密文。

按照官方在《Custom Database Integration Guide》中给出的示例,结合所建立的测试数据库在conf/openfire.xml中加入了以下代码:
  <provider>
    <auth>
      <className>org.jivesoftware.openfire.auth.JDBCAuthProvider</className>
    </auth>
    <user>
      <className>org.jivesoftware.openfire.user.JDBCUserProvider</className>
    </user>
  </provider>
  <jdbcAuthProvider>
     <passwordSQL>SELECT upass FROM user WHERE uname=?</passwordSQL>
     <passwordType>plain</passwordType>
  </jdbcAuthProvider>
  <jdbcUserProvider>
     <loadUserSQL>SELECT uname,email FROM user WHERE uname=?</loadUserSQL>
     <userCountSQL>SELECT COUNT(*) FROM user</userCountSQL>
     <allUsersSQL>SELECT uname FROM user</allUsersSQL>
     <searchSQL>SELECT uname FROM user WHERE</searchSQL>
     <usernameField>uname</usernameField>
     <nameField>uname</nameField>
     <emailField>email</emailField>
  </jdbcUserProvider>
但事实证明是不正确的。当重启服务端后,logs/warn.log给出了以下出错警告:
2010.03.23 23:39:44 Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.
2010.03.23 23:39:44 Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.
2010.03.23 23:42:41 Property 'provider.auth.className' as specified in openfire.xml differs from what is stored in the database.  Please make property changes in the database instead of openfire.xml.
2010.03.23 23:42:41 Property 'provider.user.className' as specified in openfire.xml differs from what is stored in the database.  Please make property changes in the database instead of openfire.xml.
可见,官方所说通过修改openfire.xml这个配置文件进行整合是不正确的。

经测试,在mysql中执行以下代码,可以有效进行集成:
;//-----------------------------------------------------------------------------------------------------------
UPDATE `openfire`.`ofProperty` SET propValue='org.jivesoftware.openfire.user.JDBCUserProvider' WHERE name='provider.user.className';
UPDATE `openfire`.`ofProperty` SET propValue='org.jivesoftware.openfire.auth.JDBCAuthProvider' WHERE name='provider.auth.className';
INSERT INTO `openfire`.`ofProperty` VALUES  ('jdbcProvider.driver','com.mysql.jdbc.Driver'),
('jdbcProvider.connectionString','jdbc:mysql://localhost:3306/test?user=admin&password=admin'),
('admin.authorizedJIDs','admin@localhost,test@localhost'),
('jdbcAuthProvider.passwordSQL','SELECT upass FROM user WHERE uname=?'),
('jdbcAuthProvider.passwordType','plain'),
('jdbcUserProvider.loadUserSQL','SELECT uname,email FROM user WHERE uname=?'),
('jdbcUserProvider.userCountSQL','SELECT COUNT(*) FROM user'),
('jdbcUserProvider.allUsersSQL','SELECT uname FROM user'),
('jdbcUserProvider.searchSQL','SELECT uname FROM user WHERE'),
('jdbcUserProvider.usernameField','uname'),
('jdbcUserProvider.nameField','uname'),
('jdbcUserProvider.emailField','email');
;//-----------------------------------------------------------------------------------------------------------
若要继续整合用户组等信息,可以参考《Custom Database Integration Guide》,把相关属性添加到ofProperty数据表中。

转载于:https://www.cnblogs.com/IamThat/archive/2013/05/22/3093194.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值