S
Stefan Meyer
Hello i try the code below but in the for each i get an error. now
datatype allowed
How can i fix this i need two layers
public static HashMap<String, HashMap> data = new
LinkedHashMap<String, HashMap>();
public void getConfig() {
String strSQL = "";
JDb db = new JDb();
db.ConnectDb();
strSQL = "SELECT " +
" CID, " +
" ckey," +
" cvalue," +
" cdescription " +
"FROM " +
" config " +
"ORDER BY " +
" ckey";
db.makeQuery(strSQL);
try {
while (db.rs.next()) {
HashMap<String, String> c = new LinkedHashMap<String,
String>();
c.clear();
c.put("CID", db.rs.getString("CID"));
c.put("ckey", db.rs.getString("ckey"));
c.put("cvalue", db.rs.getString("cvalue"));
c.put("cdescription", db.rs.getString("cdescription"));
data.put("sys",c);
}
} catch (SQLException e) {
System.out.println("SQL Exception: " + e.toString());
}
// Einzelwert
HashMap item = (HashMap) data.get(0);
System.out.println("Einzelwerttest: " +item.get(""));
// ALle Werte ausgeben
for (HashMap<String, HashMap> c : data) {
for (String key : c.keySet()) {
System.out.println(key + ": " + c.get(key));
}
}
// System.out.println(((HashMap)data.get(0)).get("Marke"));
// System.out.println(((HashMap) data.get(0)).get("Marke"));
// System.out.println(data);
}
}
datatype allowed
How can i fix this i need two layers
public static HashMap<String, HashMap> data = new
LinkedHashMap<String, HashMap>();
public void getConfig() {
String strSQL = "";
JDb db = new JDb();
db.ConnectDb();
strSQL = "SELECT " +
" CID, " +
" ckey," +
" cvalue," +
" cdescription " +
"FROM " +
" config " +
"ORDER BY " +
" ckey";
db.makeQuery(strSQL);
try {
while (db.rs.next()) {
HashMap<String, String> c = new LinkedHashMap<String,
String>();
c.clear();
c.put("CID", db.rs.getString("CID"));
c.put("ckey", db.rs.getString("ckey"));
c.put("cvalue", db.rs.getString("cvalue"));
c.put("cdescription", db.rs.getString("cdescription"));
data.put("sys",c);
}
} catch (SQLException e) {
System.out.println("SQL Exception: " + e.toString());
}
// Einzelwert
HashMap item = (HashMap) data.get(0);
System.out.println("Einzelwerttest: " +item.get(""));
// ALle Werte ausgeben
for (HashMap<String, HashMap> c : data) {
for (String key : c.keySet()) {
System.out.println(key + ": " + c.get(key));
}
}
// System.out.println(((HashMap)data.get(0)).get("Marke"));
// System.out.println(((HashMap) data.get(0)).get("Marke"));
// System.out.println(data);
}
}