我的结果如下:
tablename columnname size order
employee name 25 1
employee sex 25 2
employee contactNumber 50 3
address name 25 4
address street 25 5
address country 25 6
这是我的 java 代码,用于根据table name
public void getReportQuery() {
String tablename="",columnname="";
int size=0,order=0;
boolean isCustomised=true;
StringBuffer sb = new StringBuffer();
Map<String, Map<String, String>> reportQueryMap = new HashMap<String, Map<String, String>>();
List<String> reportQueryTableNameList = new ArrayList<String>();
Connection connection = getConnection();
if (connection != null) {
try {
sb.append("SELECT rmaster.tablename,rmaster.columnname,r.size,r.order FROM report_customise_child r,report_customise_master rmaster where r.isactive='y' and rmaster.id=r.masterid; ");
PreparedStatement reportQueryPS = connection.prepareStatement(sb.toString());
ResultSet reportQuery_rst= reportQueryPS.executeQuery();
if(reportQuery_rst!=null){
while (reportQuery_rst.next()) {
tablename = reportQuery_rst.getString("tablename");
if (!reportQueryTableNameList.contains(tablename)) {
reportQueryTableNameList.add(tablename);
System.out.println("tablename : "+tablename);
}
columnname = reportQuery_rst.getString("columnname");
System.out.println(" columnname : "+columnname);
//size = reportQuery_rst.getInt("size");
//order = reportQuery_rst.getInt("order");
}
}else{
isCustomised=false;
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
closeConnection(connection, null, null);
} catch (Exception ex) {
ex.printStackTrace();
}
}
} else {
System.out.println("Connection not Established. Please Contact Vendor");
}
}
我真的不知道如何对值进行分组,我想从上面的结果中构造查询。
请帮助我对值进行分组,我将从分组值中构造查询。
我需要像下面这样分组
tablename1
columnmaes
tablename2
columnnames
tablenameN
columnnames
请帮助我实现这一目标,
问候