我是新手JAVA。我有一个配置文件
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
然后我的代码
public class Main {
public static void main(String args[]) throws Exception {
ApplicationContext context = new ClassPathXmlApplicationContext("context.config.xml");
DataSource dataSource = (DataSource) context.getBean("dataSource");
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String lastName = jdbcTemplate.queryForObject(
"select a.firstname from TEST a",
new Object[]{1212L}, String.class);
System.out.println(lastName);
}
}
当我运行它时,它返回错误无效的列索引。谁能帮我 ?
谢谢