设为首页 加入收藏

TOP

Joomla Java 批量导入用户(二)
2014-11-24 02:26:18 来源: 作者: 【 】 浏览:4
Tags:Joomla Java 批量 导入 用户
ow(), )");
ps.setString(1, name);
ps.setString(2, username);
ps.setString(3, usertype);
ps.setString(4, email);
ps.setString(5, param);


ps.setString(6,group_id);
ps.execute();
ps.close();
String sql = "Select LAST_INSERT_ID()";
Statement statement = m_connection.createStatement();
ResultSet rs = statement.executeQuery(sql);
int id1 = 0;
while (rs.next()) {
id1 = rs.getInt(1);
}
rs.close();
statement.close();
String section_value = "users";
String value = id1 + "";
ps = this.m_connection.prepareStatement(
"INSERT INTO jos_core_acl_aro (section_value,value,name) VALUES( , , )");
ps.setString(1, section_value);
ps.setString(2, value);
ps.setString(3, name);
ps.execute();
ps.close();


statement = m_connection.createStatement();
rs = statement.executeQuery(sql);
int id2 = 0; //
while (rs.next()) {
id2 = rs.getInt(1);
}
rs.close();
statement.close();


section_value = "";


/*
id parent_id name lft rgt value
17 0 ROOT 1 22 ROOT
18 29 Registered 4 11 Registered
19 18 Author 5 10 Author
20 19 Editor 6 9 Editor
21 20 Publisher 7 8 Publisher
23 30 Manager 14 19 Manager
24 23 Administrator 15 18 Administrator
25 24 Super Administrator 16 17 Super Administrator
28 17 USERS 2 21 USERS
29 28 Public Frontend 3 12 Public Frontend
30 28 Public Backend 13 20 Public Backend


*/
ps = this.m_connection.prepareStatement("INSERT INTO jos_core_acl_groups_aro_map (group_id,section_value,aro_id) VALUES( , , )");
ps.setInt(1, group_id);
ps.setString(2, section_value);
ps.setInt(3, id2);
ps.execute();
ps.close();
s.message = "name:" + name + " username:"+username+"userid:" + id1 + ";acl id:" +
id2;


} catch (Exception e) {
System.out.println(e.toString());
e.printStackTrace();
s.message = e.toString();
return s;
}


return s;
}
else
{
//System.out.println(username+" 这个用户已经存在");
s.stateid=-1;
s.message=username+" 这个用户已经存在";
return s;
}


}



public static void main(String[]args)
{
DB d=new DB();


String filepath="c:\\input.txt";
try{
BufferedReader Input1 = new BufferedReader(new FileReader(
filepath));
String temp;
temp = Input1.readLine();


while (temp != null) {
String strs[]=temp.split(",");
Status s=d.Addusers(strs[0].trim(),strs[1].trim(), strs[2].trim(), strs[3].trim(),strs[4].trim(), "admin_language=zh-CN\nlanguage=zh-CN\neditor=tinymce\nhelpsite=\ntimezone=8\n\n");
System.out.println(s.message);
temp=Input1.readLine();
}
}
catch(Exception ex)
{
ex.printStackTrace();
}


//System.out.println(d.isExist("zhangtonghu"));


}


}



input 文件的格式是:
name,username,密码,邮箱,用户类型
XXX,tuyaoxu,111111,XXX@ccb.cn,Author


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Ubuntu 9.04下open函数编译不过的.. 下一篇Ubuntu下GCC 3.4与4.3共存及编译B..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: