0
我运行这段代码:如何使用列表中的值分配变量?
int key = 25;
String query = "Select one, two, three, four, five from myTable where key=?";
List<Map<String,Object>> data = jdbcTemplate.queryForList(query, new Object[]{key});
//one is string, two is int, three is character, four is double, five is string
String one = null;
int two = 0;
char three = '\u0000';
double four = 0.0;
String five = null;
我想设置上面列表中返回的值的五个变量。怎么样?
two =(int)row.get(“two”)会抛出错误。由于该值是一个对象。对象到int分析无效。 – Nik
@Nikunj:谢谢,你正在阅读帖子的第一个副本,在我的早晨大脑中,这是依靠自动装箱。但是自动装箱在这里不适用,所以我解决了它。 :-) –
@T。 J. Crowder:谢谢..它的工作..张贴在牧场上的答案也与信贷给你:) :) – Nik