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