How can i make a 2 layer structure?

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);

}
}
 
J

Joshua Cranmer

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 static Map<String, Map<String, String>> data;

That works surprisingly well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top