I've recently discovered that instead of using
DriverManager.getConnection("jdbc:mysql://localhost/DBname", "username", "password");
to connect to a database, you can use @Resource annotation to inject into a DataSource which will pool the connection rather than repeatedly open and close like the above, but the example I saw in a book only gave an example of:
private DataSource dataSource;
and nothing else.
My question is, how would I modify the first piece of code to work with the above @Resource style? I've tried playing around with it, but to no avail.