Reputation: 1614
If I want to read the data from oracle table using hashmap then i can read it like this.........
String sql = "select * from DPY_VW_REP_DELIVERY_DTLS where weighed_date between ? and ?";
Object[] queryParams = new Object[] {dateFrom, dateTo};
List rsList = this.getJdbcTemplate().queryForList(sql, queryParams);
Iterator it = rsList.iterator();
while(it.hasNext())
{
try
{
LinkedHashMap map = (LinkedHashMap) it.next();
String[] strData = new String[14];
strData[0] = map.get("WEIGHED_DATE_AS_CHAR").toString();
strData[1] = map.get("WEIGHED_DAY_SLNO").toString();
strData[2] = map.get("PARTY_NAME").toString();
strData[3] = map.get("PARTY_ADDRESS1").toString();
strData[4] = map.get("PARTY_ADDRESS2").toString();
strData[5] = map.get("VEHICLE_NO").toString();
}
}
but if I want to read an xls file containing same data using hashmap how can i do it....
Upvotes: 0
Views: 1080
Reputation: 21223
Not sure what you mean by 'using hashmap'. JdbcTemplate.queryForList
returns results mapped to a List of HashMaps.
It maybe easier to read excel files using Apache POI or similar tools. Alternatively, if using a spreadsheet as a database, you can use JDBC-ODBC
bridge. Then you can execute your SQL
query. Here is an example for this approach.
Upvotes: 1