<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://wiki.rifidi.net/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.rifidi.net/index.php?action=history&amp;feed=atom&amp;title=Database_Tutorial_Data_Access_Object</id>
		<title>Database Tutorial Data Access Object - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.rifidi.net/index.php?action=history&amp;feed=atom&amp;title=Database_Tutorial_Data_Access_Object"/>
		<link rel="alternate" type="text/html" href="https://wiki.rifidi.net/index.php?title=Database_Tutorial_Data_Access_Object&amp;action=history"/>
		<updated>2026-06-15T11:20:19Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.1</generator>

	<entry>
		<id>https://wiki.rifidi.net/index.php?title=Database_Tutorial_Data_Access_Object&amp;diff=2674&amp;oldid=prev</id>
		<title>Kyle: /* Properly closing the Database connection */</title>
		<link rel="alternate" type="text/html" href="https://wiki.rifidi.net/index.php?title=Database_Tutorial_Data_Access_Object&amp;diff=2674&amp;oldid=prev"/>
				<updated>2009-12-03T22:20:42Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Properly closing the Database connection&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 22:20, 3 December 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 101:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 101:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Properly closing the Database connection==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Properly closing the Database connection==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;This DAO does not properly shut down the JDBC connection. You could possibly add a method called &amp;lt;tt&amp;gt;close()&amp;lt;/tt&amp;gt; to the DAO interface and then let the DBApp object call this method when its stop method is called.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Kyle</name></author>	</entry>

	<entry>
		<id>https://wiki.rifidi.net/index.php?title=Database_Tutorial_Data_Access_Object&amp;diff=2673&amp;oldid=prev</id>
		<title>Kyle: /* Query the database */</title>
		<link rel="alternate" type="text/html" href="https://wiki.rifidi.net/index.php?title=Database_Tutorial_Data_Access_Object&amp;diff=2673&amp;oldid=prev"/>
				<updated>2009-12-03T22:19:08Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Query the database&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 22:19, 3 December 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 94:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 94:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Here are a few ideas for extra functionality that might be useful for this DAO to have&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Here are a few ideas for extra functionality that might be useful for this DAO to have&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Query the database==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Query the database==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;This particular application only writes some basic information to the DB. One thing that you could do with the SimpleJdbcTemplate is to query the database. For example, you could write a method in the interface:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;pre&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;List&amp;lt;RFIDEvent&amp;gt; queryByReader(String readerID);&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/pre&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;This method would allow an object that has access to the DAO (for example, the DBApp) to get a list of tags that has been seen by a certain reader.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Properly closing the Database connection==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Properly closing the Database connection==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Kyle</name></author>	</entry>

	<entry>
		<id>https://wiki.rifidi.net/index.php?title=Database_Tutorial_Data_Access_Object&amp;diff=2668&amp;oldid=prev</id>
		<title>Kyle: /* Extensions */</title>
		<link rel="alternate" type="text/html" href="https://wiki.rifidi.net/index.php?title=Database_Tutorial_Data_Access_Object&amp;diff=2668&amp;oldid=prev"/>
				<updated>2009-12-03T21:54:04Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Extensions&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 21:54, 3 December 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 91:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 91:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This method is self-evident. Whenever it is called with an RFID event object, it creates a map containing the information to be inserted and the columns to insert that data into. Then it inserts a new row into the database.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This method is self-evident. Whenever it is called with an RFID event object, it creates a map containing the information to be inserted and the columns to insert that data into. Then it inserts a new row into the database.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Extensions&lt;/del&gt;=&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Extra Credit&lt;/ins&gt;=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Here are a few ideas for extra functionality that might be useful for this DAO to have&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Query the database==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Query the database==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Properly closing the Database connection==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Properly closing the Database connection==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Kyle</name></author>	</entry>

	<entry>
		<id>https://wiki.rifidi.net/index.php?title=Database_Tutorial_Data_Access_Object&amp;diff=2665&amp;oldid=prev</id>
		<title>Kyle at 21:38, 3 December 2009</title>
		<link rel="alternate" type="text/html" href="https://wiki.rifidi.net/index.php?title=Database_Tutorial_Data_Access_Object&amp;diff=2665&amp;oldid=prev"/>
				<updated>2009-12-03T21:38:01Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 21:38, 3 December 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 93:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 93:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=Extensions=&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=Extensions=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Query the database==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Query the database==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;==Properly closing the Database connection==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Kyle</name></author>	</entry>

	<entry>
		<id>https://wiki.rifidi.net/index.php?title=Database_Tutorial_Data_Access_Object&amp;diff=2664&amp;oldid=prev</id>
		<title>Kyle: New page: A Data Access Object is an object-oriented pattern that is often used in conjunction with databases to hide the details of interfacing with a database. In our case, it allows us to encapsu...</title>
		<link rel="alternate" type="text/html" href="https://wiki.rifidi.net/index.php?title=Database_Tutorial_Data_Access_Object&amp;diff=2664&amp;oldid=prev"/>
				<updated>2009-12-03T21:37:17Z</updated>
		
		<summary type="html">&lt;p&gt;New page: A Data Access Object is an object-oriented pattern that is often used in conjunction with databases to hide the details of interfacing with a database. In our case, it allows us to encapsu...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;A Data Access Object is an object-oriented pattern that is often used in conjunction with databases to hide the details of interfacing with a database. In our case, it allows us to encapsulate all the work of talking with JDBC so that none of that logic is included in the DBApp class.&lt;br /&gt;
=The DAO interface=&lt;br /&gt;
The first step is to create an interface class that the DBApp can use to add new RFIDEvent objects to the database. For now, we will keep it very simple:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * This interface is implemented by Data Access Objects (DAO) that have the&lt;br /&gt;
 * ability to write to our data source.&lt;br /&gt;
 * &lt;br /&gt;
 * @author Kyle Neumeier - kyle@pramari.com&lt;br /&gt;
 * &lt;br /&gt;
 */&lt;br /&gt;
public interface RFID_DAO {&lt;br /&gt;
&lt;br /&gt;
	/***&lt;br /&gt;
	 * Write the supplied event to the data source&lt;br /&gt;
	 * &lt;br /&gt;
	 * @param event&lt;br /&gt;
	 */&lt;br /&gt;
	public void addRow(RFIDEvent event);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=The DAO Implementation=&lt;br /&gt;
The next step is to create an object that implements the &amp;lt;tt&amp;gt;RFID_DAO&amp;lt;/tt&amp;gt; interface and can use JDBC to write to a database.&lt;br /&gt;
==Define the table and column names==&lt;br /&gt;
To make sure that we use the same table and column names throughout the application, let's define some static final members:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	/** The name of the table to write to */&lt;br /&gt;
	private static final String TABLE = &amp;quot;rfidevents&amp;quot;;&lt;br /&gt;
	/** The name of the ID column in the table */&lt;br /&gt;
	private static final String COL_ID = &amp;quot;id&amp;quot;;&lt;br /&gt;
	/** The name of the reader column in the table */&lt;br /&gt;
	private static final String COL_READER = &amp;quot;reader&amp;quot;;&lt;br /&gt;
	/** The name of the antenna column in the table */&lt;br /&gt;
	private static final String COL_ANT = &amp;quot;antenna&amp;quot;;&lt;br /&gt;
	/** The name of the time column in the table */&lt;br /&gt;
	private static final String COL_TIME = &amp;quot;time&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==Dependency Injection==&lt;br /&gt;
Like the DBApp class, the DAO should have its dependencies injected by spring. In this case, we only have one dependency:&lt;br /&gt;
;SimpleDriverDataSource&lt;br /&gt;
:This object contains the information about how to connect to a database: the JDBC driver to use, the URL of the database, and the username and pass.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	/**&lt;br /&gt;
	 * Method called by spring to inject the datasource. This method also opens&lt;br /&gt;
	 * up the connection to the datasource.&lt;br /&gt;
	 * &lt;br /&gt;
	 * @param ds&lt;br /&gt;
	 */&lt;br /&gt;
	public void setDataSource(SimpleDriverDataSource ds) {&lt;br /&gt;
		this.ds = ds;&lt;br /&gt;
		template = new SimpleJdbcTemplate(ds);&lt;br /&gt;
&lt;br /&gt;
		// first thing to do is to drop the table if it exists already.&lt;br /&gt;
		try {&lt;br /&gt;
			template.update(&amp;quot;drop table &amp;quot; + TABLE, new Object[] {});&lt;br /&gt;
			logger.debug(&amp;quot;RFIDEVENTS table dropped&amp;quot;);&lt;br /&gt;
		} catch (DataAccessException dae) {&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		// next create the table&lt;br /&gt;
		template.update(&amp;quot;create table &amp;quot; + TABLE + &amp;quot;(&amp;quot; + COL_ID&lt;br /&gt;
				+ &amp;quot; VARCHAR(24), &amp;quot; + COL_READER + &amp;quot; VARCHAR(50),&amp;quot; + COL_ANT&lt;br /&gt;
				+ &amp;quot; INTEGER, &amp;quot; + COL_TIME + &amp;quot; TIMESTAMP)&amp;quot;, new Object[] {});&lt;br /&gt;
		logger.debug(&amp;quot;New RFIDEVENTS table created&amp;quot;);&lt;br /&gt;
		insertRFIDEvent = new SimpleJdbcInsert(ds).withTableName(TABLE);&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This setter method is a bit more complicated than the one in the DBApp class. Whenever spring hands the DAO a new datasource, it needs to do some setup.&lt;br /&gt;
First, it needs to create the &amp;lt;tt&amp;gt;SimpleJdbsTemplate&amp;lt;/tt&amp;gt; which is a helper class provided by spring that simplifies JDBC database access. Next it attempts to drop the table if it has already been created. Then it tries to create the table. There are definitely more sophisticated ways to ensure that a table exists and that there are no rows in it, but this is simple enough. Finally, the setter method creates another spring helper object called SimpleJdbcInsert which (as the name implies) simplifies the process of writing a new row in the database.&lt;br /&gt;
==Add Rows==&lt;br /&gt;
The last piece of functionality that the DAO needs is to implement the addRow method from its interface.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	/*&lt;br /&gt;
	 * (non-Javadoc)&lt;br /&gt;
	 * &lt;br /&gt;
	 * @see&lt;br /&gt;
	 * org.rifidi.edge.app.db.dao.RFIDDAO#addRow(org.rifidi.edge.app.db.domain&lt;br /&gt;
	 * .RFIDEvent)&lt;br /&gt;
	 */&lt;br /&gt;
	@Override&lt;br /&gt;
	public void addRow(RFIDEvent event) {&lt;br /&gt;
		Map&amp;lt;String, Object&amp;gt; parameters = new HashMap&amp;lt;String, Object&amp;gt;();&lt;br /&gt;
		parameters.put(COL_ID, event.getId());&lt;br /&gt;
		parameters.put(COL_READER, event.getReader());&lt;br /&gt;
		parameters.put(COL_ANT, event.getAntenna());&lt;br /&gt;
		parameters.put(COL_TIME, new Timestamp(event.getTimestamp()));&lt;br /&gt;
		insertRFIDEvent.execute(parameters);&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This method is self-evident. Whenever it is called with an RFID event object, it creates a map containing the information to be inserted and the columns to insert that data into. Then it inserts a new row into the database.&lt;br /&gt;
=Extensions=&lt;br /&gt;
==Query the database==&lt;/div&gt;</summary>
		<author><name>Kyle</name></author>	</entry>

	</feed>