One
CHAPTER 5 ?– A DATABASE-DRIVEN SHOP 89
of the more common problems is differences in SQL quoting, which differ between database
vendors. So, there still has to be some support code for each database, but the difference compared
to regular Rails is that this code won??™t be so big, and it is easy to add this code to the
system.
Further, not only can you use regular JDBC drivers to connect to databases; you can also
use other deployment patterns for database access that make more sense in a Java enterprise
environment. This support is continually evolving, but at the moment you can use simple
JDBC drivers of all kinds, and you can also fetch a DataSource from Java Naming and Directory
Interface (JNDI). Making it possible to use data sources opens up a few different possibilities.
First of all, you can deploy database handles in an application server and the Rails application
can fetch connections from that point. By splitting the configuration like this, it becomes easy
to change the back-end database, make configuration changes, and even enable failover on
the database, totally transparently from the Rails application. Another important possibility
is the usage of database pooling. In regular Rails, some of the database adapters support pooling,
but this is implemented inside the database-specific database driver. With Java, it??™s easy to
use one of the many open source database pooling tools that exist; for example, Jakarta Commons
DBCP is good enough for most purposes.
Pages:
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172