JSONObject cannot be resolved to a type
public String addUser(String json)
{
JSONObject jsonObj = JSONObject.fromObject(json);
JSONObject outJson = new JSONObject();
Users user = (Users) JSONObject.toBean(jsonObj, Users.class);
try {
connection = dataSource.getConnection();
if (connection != null) {
connection.setAutoCommit(false);
String sql = "insert into users (id, name, email, qq,phone) values (?,?,?,?,?)";
pst = connection.prepareStatement(sql);
pst.setString(1, YyID.getUUID32());
pst.setString(2, user.getName());
pst.setString(3, user.getEmail());
pst.setString(4, user.getQq());
pst.setString(5, user.getPhone());
int count = pst.executeUpdate();
connection.commit();
connection.setAutoCommit(true);
if (count == 1) {
outJson.put("retCode", "0100");
outJson.put("retMsg", "add employee successfully.");
} else {
outJson.put("retCode", "0001");
outJson.put("retMsg", "add employee failed.");
}
}
} catch (SQLException e) {
try {
if (connection != null)
connection.rollback();
connection.setAutoCommit(true);
} catch (SQLException e1) {
e1.printStackTrace();
}
outJson.put("retCode", "0003");
outJson.put("retMsg", "mysql execute error.");
e.printStackTrace();
} finally {
try {
if (pst != null)
pst.close();
if (connection != null)
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return outJson.toString();
}