So a little while ago, I wrote about jdbc and guice.. I’ve been using mybatis since then.. And it just came to me yesterday “with mybatis you can do simple jdbc with guice”. Something similar to Spring JDBC templates.
So heres how (integer select), using annotation approach in something called a mapper class.
@Select(value = "select ${sql}")
public Integer updateCustomerEntrance(@Param("sql") String sql);
Thats it the only stuff you need to ensure are that your select will return an integer, and thats it. Mybatis will manage connection pool, connection etc for you.
It’s probably also possible for you to just return a object.. you’ll need at least 3 methods one for each type of sql, select update and delete.
However this approach are not at all utilizing mybatis’s power and are prone to SQL injection.. But it will do the job, and you can then go ahead an convert your legacy code slowly to use mybatis’s full potential.
Heres howto setup guice using it:
http://code.google.com/p/mybatis/wiki/Guice