日期:2014-05-16  浏览次数:20455 次

openfire 使用其他数据库的用户

摘抄 http://www.cnblogs.com/hannover/archive/2008/12/12/1353806.html

?

?

?

1、启动ajmessage服务器,然后进入

http://172.16.15.110:9090/server-properties.jsp (系统属性配置)

?

insert into ofproperty( name, propValue) values( 'jdbcAuthProvider.passwordSQL' ? ?, ? 'select pass from user where name=?' ?);

?

insert into ofproperty( name, propValue) values( 'jdbcAuthProvider.passwordType' ? , ? 'plain' ?);

//plain属性表示是对密码不做任何加密处理

//md5?

//sha1?

//sha256?

//sha512?

?

insert into ofproperty( name, propValue) values( ?'jdbcProvider.connectionString' ? , ? 'jdbc:mysql://172.16.32.72:3306/hb?user=root&password=admin' );

insert into ofproperty( name, propValue) values( ?'jdbcProvider.driver' ? ? ? ? ? ? , ? 'com.mysql.jdbc.Driver' );

?

//用户登录使用(根据用户名来)

insert into ofproperty( name, propValue) values( ? 'jdbcUserProvider.loadUserSQL' ? ?, ? 'SELECT id,name,pass from user where name=?');

//查看所有用户使用

insert into ofproperty( name, propValue) values( ?'jdbcUserProvider.allUsersSQL' ? ?, ? 'select name from user' );

?

insert into ofproperty( name, propValue) values( ?'provider.auth.className' ? ?, ? 'org.jivesoftware.openfire.auth.JDBCAuthProvider' );

?

insert into ofproperty( name, propValue) values( ?'provider.user.className' ? ?, ? 'org.jivesoftware.openfire.user.JDBCUserProvider' );

?

//所有的用户数量,用来分页处理

insert into ofproperty( name, propValue) values( ?'jdbcUserProvider.userCountSQL' ? ?, ? 'SELECT count(id) from user' );

?

?

2、目标表的结构

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------

-- Table structure for `user`

-- ----------------------------

DROP TABLE IF EXISTS `user`;

CREATE TABLE `user` (

? `id` int(8) NOT NULL,

? `name` varchar(20) NOT NULL,

? `pass` varchar(64) NOT NULL,

? PRIMARY KEY (`id`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

?

-- ----------------------------

-- Records of user

-- ----------------------------

INSERT INTO `user` VALUES ('1', 'admin', 'admin');

INSERT INTO `user` VALUES ('2', 'hb', 'hb');

INSERT INTO `user` VALUES ('3', 'zqt', 'zqt');