queryForList("SELECT * FROM myTable");
The JdbcTemplate class is our gateway into the world of Spring JDBC. As you can see,
it provides a queryForList() method, which returns us a List representing the result set.
No more messing around with ResultSet objects! Other methods are provided, such as
queryForMap(), which is used to retrieve a single record from the database and get a Map in
return, making it very simple to access the fields of the record. Note that I am not showing
any connection-handling code, no cleanup code, things of that nature. That is because the
data source and template handle all that for us. No worries about closing the connection or
dealing with statements and that sort of typical JDBC work.
WHY HAS SPRING BECOME SO POPULAR SO FAST?
The rapid rise of Spring is largely due to the core beliefs that its original creator, Rod Johnson, founded the
project on. His belief is that programming in the J2EE world is far too complex and can be simplified by
working ???around??? the specs. This sounds a bit controversial (although it happens to be a nearly verbatim
quote from Rod himself), but I think what he really meant was that you could build something on top of the
specs that actually made them simpler.
Pages:
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367