一次,用到了LinkedList<HashMap<String, String>> retList=new LinkedList<HashMap<String,String>>();
使用背景:
/**
* 查询记录封装在list中
* @param conn
* @param sql
* @return
* @throws SQLException
*/
public static LinkedList<HashMap<String, String>> getListRecords(Connection conn, String sql) throws SQLException;
HashMap中存放的是:
ResultSetMetaData rsmd = rs.getMetaData() ;
String[] columns = getColumnName(rsmd);
while (rs.next())
{
recordMap = new HashMap<String, String>();
for (int i = 0; i < columns.length; i++)
{
recordMap.put(columns[i], rs.getString(columns[i]));
}
retList.add(recordMap);
}
在取出HashMap后,总是get不到HashMap值,字段名是数据库中搜出的列名busi_code......
HashMap.get("busi_code")=NULL
相关JDK: 方法无字段大小写的规定
java.sql
Interface ResultSetMetaData
getColumnName
String getColumnName(int column)
throws SQLExceptionGet the designated column's name.
Parameters:
column - the first column is 1, the second is 2, ...
Returns:
column name
Throws:
SQLException - if a database access error occurs
--------------------------------------------------------------------------------
SQL语句:
select busi_code from tb_experience_interface where busi_flag='1';
经过遍历HashMap中的值:
for(HashMap<String, String> record:retList)
{
for (Map.Entry entry : record.entrySet()) {
Object key = entry.getKey( );
Object value = entry.getValue();
System.out.print("KEY:" + key + "\t");
System.out.println("VALUE:" + value);
}
// String busiCode=record.get("BUSI_CODE");
}
最后发现HashMap中存的值:KEY:BUSI_CODE VALUE:7450
费尽周折,发现原因尽然是Oracle会将所有表名和字段名变为大写......
分享到:
相关推荐
20-集合框架020-HashMap-1080P 高清-AVC20
1.说一下 HashMap 的实现原理? 2.HashMap在JDK1.7和JDK1.8中有哪些不同?HashMap的底层实现? 3.HashMap的put方法的具体流程? 4.HashMap的扩容操作是怎么实现的? 5.HashMap是怎么解决哈希冲突的? 6.什么是哈希?...
Java、hashMap
A simple C hashmap
官方
Create Hash map and Hash function
泛型HashMap-Java Java的通用HashMap
java-HashMap-loop
dsa-hashmap-practice
grunt-hashmap-ext 更改 php 文件结果以返回数组而不是创建变量
读取excel文件数据,封装成hashmap-附件资源
看完这篇 HashMap,和面试官扯皮就没问题了 - HashMap 概述 - HashMap 和 HashTable 的区别 - 相同点 - 不同点 - HashMap 和 HashSet 的区别 - HashMap 底层结构 - AbstractMap 类 - Map 接口 - 重要内部类...
HashMap的用法---马克-to-win java视频的详细描述与介绍
哈希映射线程测试使用 Maven 构建和运行 mvn exec:java
Hashmap的原生实现,相比大多数的版本,速度是其优势。
HashMap的treeifyBin()方法源码 final void treeifyBin(Node[] tab, int hash) { //定义几个变量,n是数组长度,index是索引 int n, index; Node e; //这里的tab指的是本HashMap中的数组,n为数字长度,如果数组...
java提高篇(二三)-----HashMap.pdf