i am getting some records from database and adding in HashMap<Integer, Object> .Then i am adding this HashMap to a Vector<HashMap<Integer, Object>>. Now problem is when. I am printing the Vector, I am not getting the records in the same insertion order ... Please help.
public Vector<HashMap<Integer, Object>> executeQueryAsIntegerColumnNames(String aQuery, HashMap<String,String> conditions, String likeQuery){ LOGGER.info("Query in Execute:"+aQuery); LOGGER.info("Query in Execute:"+conditions); LOGGER.info("Query in Execute:"+likeQuery); Vector <HashMap<Integer,Object>> result = null; Connection conn = connection.getMySQLConnection(); String concond = this.getConditions(conditions); try { Statement stmt = conn.createStatement(); stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(aQuery + concond); ResultSetMetaData metaInfo = null; if(rs != null){ metaInfo =rs.getMetaData(); } while(rs != null && rs.next()){ if(result == null){ result = new Vector<HashMap<Integer, Object>>(); } HashMap<Integer, Object> row = new HashMap<Integer, Object>(); for(int i = 1 ; i <= metaInfo.getColumnCount(); i++){ row.put(i, rs.getObject(i)); } result.add(row); } }catch(Exception ex){ LOGGER.error("executeQueryAsIntegerColumnNames : "+ex); }finally{ try { conn.close(); } catch (SQLException e) { LOGGER.error("Exception :",e); } } LOGGER.info("Befor Returning to Caller : "+result.toString()); return result; } Does Vector support insertion Order??? IF YES then This is my OutPut Please have a look
Befor Returning to Caller : [{1=mah0300537, 2=nabi hussain, 3=Mah03, 4=05:50:00 PM, 5=233346, 6=0}, {1=cha0700003, 2=sita sharan ray, 3=cha07, 4=05:50:00 PM, 5=233347, 6=2}]
Befor Returning to Caller : [{1=cha0700003, 2=sita sharan ray, 3=cha07, 4=05:50:00 PM, 5=233347, 6=2}, {1=mah0300537, 2=nabi hussain, 3=Mah03, 4=05:50:00 PM, 5=233346, 6=0}]