Difference between revisions of "Database Tutorial"

From RifidiWiki

Jump to: navigation, search
(Download the Source)
 
(6 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
=Download and Run the Application=
 
=Download and Run the Application=
 +
If you are interested in running the application, you can [http://rifidi.org/apps/dbapp/dbapp.zip download] it and unzip it into the applications folder of your Rifidi Edge Server installation.
 +
 
This section provides instructions on how to download the final application and run it. It assumes you already have downloaded and installed the edge server and that you know how to read tags. If you need help with this see [[Edge Server Getting Started]]
 
This section provides instructions on how to download the final application and run it. It assumes you already have downloaded and installed the edge server and that you know how to read tags. If you need help with this see [[Edge Server Getting Started]]
==MySQL Configuration==
+
==Configure the database==
 
If you are using MySQL
 
If you are using MySQL
 
* First set up a MySQL instance and create a database called rifididb. There are no instructions here on how to set up MySQL on your system. There are plenty of tutorials on that, however.
 
* First set up a MySQL instance and create a database called rifididb. There are no instructions here on how to set up MySQL on your system. There are plenty of tutorials on that, however.
Line 15: Line 17:
 
</pre>
 
</pre>
  
==Derby Configuration==
+
 
 
If you are using Derby
 
If you are using Derby
 
* You don't need to configure a derby DB in the same way you have to configure a MySQL DB, since it is embedded.
 
* You don't need to configure a derby DB in the same way you have to configure a MySQL DB, since it is embedded.
Line 39: Line 41:
 
</pre>
 
</pre>
  
=Prerequisites=
+
=Exploring the Source=
 +
This section explains the source code for the DBApplication and gives hints on how you can customize it for your needs.
 +
==Prerequisites==
 
This tutorial assumes that you are using eclipse, that you have some java development experience, and that you know how to run the edge server and get tags back from it.  The [[Northwind Tutorial]] is much more in-depth than this one, and is recommended for people who have little experience with java and/or eclipse.
 
This tutorial assumes that you are using eclipse, that you have some java development experience, and that you know how to run the edge server and get tags back from it.  The [[Northwind Tutorial]] is much more in-depth than this one, and is recommended for people who have little experience with java and/or eclipse.
  
Line 46: Line 50:
 
* Create a new application project following similar directions to the northwind project: [[Northwind Creating the Application]]
 
* Create a new application project following similar directions to the northwind project: [[Northwind Creating the Application]]
 
* For more instructions about how to use emulator with your application see [[Northwind Using Emulator]]
 
* For more instructions about how to use emulator with your application see [[Northwind Using Emulator]]
 +
* Download the [http://rifidi.org/apps/dbapp/RifidiDBAppSrc.zip source] and import it into eclipse. There are instructions in the readme file about how to import it into eclipse.
  
=Download the Source=
+
==Outline==
You can download the [http://rifidi.org/apps/dbapp/RifidiDBAppSrc.zip source] and import it into eclipse. There are instructions in the readme file about how to import it into eclipse.
+
The next four sections walk you through the source code to explain how the DB App works.
 
+
* [[Database Tutorial DB Application| The DB Application]]
=Outline=
+
* [[Database Tutorial Data Access Object| The Data Access Object]]
* [[Database Tutorial Create Application| Step 1: Create the Application]]
+
* [[Database Tutorial Command Provider| The Command Provider]]
* [[Database Tutorial Implement DAO| Step 2: Implementing the DAO]]
+
* [[Database Tutorial Spring| The Spring Configuration File]]
* [[Database Tutorial Command Provider| Step 3: Create a Command Provider]]
+

Latest revision as of 19:18, 3 December 2009

This document provides instructions for creating an edge server application that logs RFID tags to a database.

Download and Run the Application

If you are interested in running the application, you can download it and unzip it into the applications folder of your Rifidi Edge Server installation.

This section provides instructions on how to download the final application and run it. It assumes you already have downloaded and installed the edge server and that you know how to read tags. If you need help with this see Edge Server Getting Started

Configure the database

If you are using MySQL

  • First set up a MySQL instance and create a database called rifididb. There are no instructions here on how to set up MySQL on your system. There are plenty of tutorials on that, however.
  • Now open up 'edge server.ini' in the edge server file and add this:
-Dorg.rifidi.jdbc.driver=com.mysql.jdbc.Driver
-Dorg.rifidi.jdbc.url=jdbc:mysql://127.0.0.1/rifididb
-Dorg.rifidi.jdbc.user=root
-Dorg.rifidi.jdbc.pass=root


If you are using Derby

  • You don't need to configure a derby DB in the same way you have to configure a MySQL DB, since it is embedded.
  • Open up 'edge server.ini' in the edge server file and add this:
-Dorg.rifidi.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver
-Dorg.rifidi.jdbc.url=jdbc:derby:RifidiDB;create=true
-Dorg.rifidi.jdbc.user
-Dorg.rifidi.jdbc.pass

Run the App

Note that you need to set the url, user, and pass to the values according to your database.

  • Start up the edge server, workbench, and start reading tags just like you are used to doing.
  • Now type this into the edge server console (at the osgi prompt)
loadApp dbapp

That is what loads the application.

  • Wait for it to tell you the bundles are loaded properly. Then type this:
dbstart

Exploring the Source

This section explains the source code for the DBApplication and gives hints on how you can customize it for your needs.

Prerequisites

This tutorial assumes that you are using eclipse, that you have some java development experience, and that you know how to run the edge server and get tags back from it. The Northwind Tutorial is much more in-depth than this one, and is recommended for people who have little experience with java and/or eclipse.

To get started

Outline

The next four sections walk you through the source code to explain how the DB App works.

Personal tools