queryForObject(String sql,Class requiredType)
引數說明:public static void main(String[] args){ ApplicationContext context = new ClassPathXmlApplicationContext("cfg/XMLConfig.xml"); //載入組態檔 Dao dao = (Dao)context.getBean("dao"); //建立Dao JdbcTemplate jtm = dao.getJdbcTemplate(); String sql = "select name from tb_user limit 1"; //建立一條SQL語句 String name = (String)jtm.queryForObject(sql,String.class); System.out.println(name); }