Java Reference
In-Depth Information
When using the resource attribute, the classloader will attempt to locate that
resource on the application's classpath. This is called a resource , because we are using
a classloader to read it. The Java documentation refers to resources when accessing
data this way, because while it may just be a file on the local files system, it is just as
possible that it is an entry in a JAR file, possibly even on a different computer.
The url attribute is handled by the class, so it can be any valid
URL that it understands and can use to load data.
In our earlier example, we used the <properties> element to keep the data-
base configuration details out of our XML file and put them in a simple properties
file called that exits on our classpath. This separation is useful for a
number of reasons, not the least of which is simplicity. Let's assume that our file contained the following four property definitions:
We refer to the properties file with the following line taken from our previous
<properties resource="" />
Finally, we use the properties by name using a syntax that will be familiar to many
<property name="JDBC.Driver" value=" ${driver} "/>
<property name="JDBC.ConnectionURL" value=" ${url} "/>
<property name="JDBC.Username" value=" ${user} "/>
<property name="JDBC.Password" value=" ${pword} "/>
At this point you should be thinking to yourself, “Gee, that looks just like the way
every other tool uses properties!”
The <settings> element
The <settings> element is a bit of a grab bag of configuration options. You set
these options by inserting attributes into the <settings> element. Several settings
are available, and each of them is global to this SQL Map instance.
Lazy loading is a technique in which you load only the information that is essential,
and defer the loading of other data until it is specifically requested. In other words,
you want to have the application do as little as possible until it is absolutely required.
Search WWH ::

Custom Search