// Path: server/4FunServer/src/com/mollychin/utils/ConstantsUtil.java
// public final static String PASSWORD = "123456";
// 
// Path: server/4FunServer/src/com/mollychin/utils/ConstantsUtil.java
// public final static String ROOT_URL = "jdbc:mysql://localhost:3306/"
// 		+ DATABASE_NAME;
// 
// Path: server/4FunServer/src/com/mollychin/utils/ConstantsUtil.java
// public final static String USER = "root";
// 
// Path: server/4FunServer/src/com/mollychin/bean/User.java
// public class User {
// 	private String userName;
// 	private String password;
// 	private int sex;
// 	private String email;
// 
// 	public String getUserName() {
// 		return userName;
// 	}
// 
// 	public void setUserName(String userName) {
// 		this.userName = userName;
// 	}
// 
// 	public String getPassword() {
// 		return password;
// 	}
// 
// 	public void setPassword(String password) {
// 		this.password = password;
// 	}
// 
// 	public int getSex() {
// 		return sex;
// 	}
// 
// 	public void setSex(int sex) {
// 		this.sex = sex;
// 	}
// 
// 	public String getEmail() {
// 		return email;
// 	}
// 
// 	public void setEmail(String email) {
// 		this.email = email;
// 	}
// }


import static com.mollychin.utils.ConstantsUtil.PASSWORD;
import static com.mollychin.utils.ConstantsUtil.ROOT_URL;
import static com.mollychin.utils.ConstantsUtil.USER;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.google.gson.Gson;
import com.mollychin.bean.User;
import com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException;
	public static String resultSet2Json(ResultSet rs) throws SQLException,
			JSONException {
		// json 对象
		JSONObject object = new JSONObject();
		boolean error = true;
		// json 数组
		JSONArray array = new JSONArray();
		// 获取列数
		ResultSetMetaData metaData = rs.getMetaData();
		int columnCount = metaData.getColumnCount();
		// 遍历ResultSet中的每条数据
		while (rs.next()) {
			JSONObject jsonObj = new JSONObject();
			// 遍历每一列
			for (int i = 1; i <= columnCount; i++) {
				String columnName = metaData.getColumnLabel(i);
				String value = rs.getString(columnName);
				jsonObj.put(columnName, value);
			}
			array.put(jsonObj);
		}
		if (array.length() > 0) {
			error = !error;
		}
		object.put("error", error);
		object.put("result", array);

		return object.toString();
	}

// Path: server/4FunServer/src/com/mollychin/utils/ConstantsUtil.java
// public final static String PASSWORD = "123456";
// 
// Path: server/4FunServer/src/com/mollychin/utils/ConstantsUtil.java
// public final static String ROOT_URL = "jdbc:mysql://localhost:3306/"
// 		+ DATABASE_NAME;
// 
// Path: server/4FunServer/src/com/mollychin/utils/ConstantsUtil.java
// public final static String USER = "root";
// 
// Path: server/4FunServer/src/com/mollychin/bean/User.java
// public class User {
// 	private String userName;
// 	private String password;
// 	private int sex;
// 	private String email;
// 
// 	public String getUserName() {
// 		return userName;
// 	}
// 
// 	public void setUserName(String userName) {
// 		this.userName = userName;
// 	}
// 
// 	public String getPassword() {
// 		return password;
// 	}
// 
// 	public void setPassword(String password) {
// 		this.password = password;
// 	}
// 
// 	public int getSex() {
// 		return sex;
// 	}
// 
// 	public void setSex(int sex) {
// 		this.sex = sex;
// 	}
// 
// 	public String getEmail() {
// 		return email;
// 	}
// 
// 	public void setEmail(String email) {
// 		this.email = email;
// 	}
// }


// Path: server/4FunServer/src/com/mollychin/utils/JDBCUtil.java
import static com.mollychin.utils.ConstantsUtil.PASSWORD;
import static com.mollychin.utils.ConstantsUtil.ROOT_URL;
import static com.mollychin.utils.ConstantsUtil.USER;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.google.gson.Gson;
import com.mollychin.bean.User;
import com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException;

	public static String resultSet2Json(ResultSet rs) throws SQLException,
			JSONException {
		// json 对象
		JSONObject object = new JSONObject();
		boolean error = true;
		// json 数组
		JSONArray array = new JSONArray();
		// 获取列数
		ResultSetMetaData metaData = rs.getMetaData();
		int columnCount = metaData.getColumnCount();
		// 遍历ResultSet中的每条数据
		while (rs.next()) {
			JSONObject jsonObj = new JSONObject();
			// 遍历每一列
			for (int i = 1; i <= columnCount; i++) {
				String columnName = metaData.getColumnLabel(i);
				String value = rs.getString(columnName);
				jsonObj.put(columnName, value);
			}
			array.put(jsonObj);
		}
		if (array.length() > 0) {
			error = !error;
		}
		object.put("error", error);
		object.put("result", array);

		return object.toString();
	}

	public static List<Object> resultSet2JSONArray(ResultSet rs)