Spring + iBatis // Part 7 // Executing a Method
Ok, so you now have everything setup. You have the libraries added, the database.properties file pointed properly, the applicationContext.xml file configured, the sql mappings file in place with the classes to support it, and the DAO interface implemented.
Now you just want to execute it and see it working, right? The snippet below will execute the query to pull back a java.util.List.
public static void main(String[] args) {
ClassPathXmlApplicationContext ctx =
new ClassPathXmlApplicationContext("applicationContext.xml");
MyDAO dao = (MyDAO) ctx.getBean("myDAO");
List<FilePickup> fp = dao.selectFilepickupInstructions();
for (FilePickup fps : fp) {
System.out.println(fps);
}
ctx.close();
}
If you spot any errors, or have any questions about these steps, please feel free to leave a comment. I can’t promise I will reply or have time to look into it.
Advertisement
