Map Adventures with Google, Oracle and Spring
In summer 2000 I started in the Field Service development team of Oracle’s eBusiness Suite (http://www.oracle.com/applications/service/srvonl_cont.html). The web form Dispatch Center contains four Java applets. One of them is a map. This map displays the location of the customers and the current position of the field service engineers who synchronize their mobile devices with a central database. The implementation of this map was quite problematic. Especially the performance caused severe headache. In 2005, five years and ten versions later, clicking the tab page of the map still was a receipt to freeze your applicationâ€¦ then I saw Google Maps and I nearly fell from my chair. The performance is amazing. But also development work to integrate a map into an application is easy.
When you have geocoded data in your database, you can display it on a Google Map running in a browser without needing an applet or plugin. For example with Spring JDBC you can easily query that data and pass it on to a JSP view. Below is presented a code example that you can copy and modify in order to create your own web page that displays data on a map. It took me one rainy afternoon to find out how to use the Google Maps API and to create the most simple J2EE application that displays database data on Google Maps. This is indeed quicker than five yearsâ€¦
Just follow the six steps below and enjoy.
Step 1.Â Â Â Download the project code
Get the code by downloading it here. Unzip it in a projects directory.
Step 2.Â Â Â Build project with Maven
Make sure you have Maven 2 installed. If not, download it from http://maven.apache.org. Navigate to directory googlemap/ and – after verifying that pom.xml is there – launch command:
This will download the project dependencies from Open Source repository on the internet to a repository on your machine (hmmâ€¦ still an old version of Spring, sorry). The Oracle JDBC drivers are not OS, so you need to add this to your local repository manually by first downloading e.g. Oracle 10g 10.2.0.1.0 JDBC drivers (ojdbc14.jar) from http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc_10201.html, and then issue the command:
>mvn install:install-file -Dfile=ojdbc14.jar-DgroupId=com.oracle.jdbc -DartifactId=ojdbc14 -Dversion=10.2.0.1.0-Dpackaging=jar -DgeneratePom=true
Now, we are ready to create an Eclipse project with the command:
Finally you should see a message that says that Eclipse project has been written to local directory googlemap/
Step 3.Â Â Â Install Oracle database
Oracle Locator is a feature of Oracle Database 10g Standard and Enterprise Editions that provides core location functionality. Information can be found at http://www.oracle.com/technology/products/spatial/index.html. The free Express Edition can be downloaded at http://www.oracle.com/technology/software/products/database/xe/index.html.Â Create user google/welcome. Grant sufficient privileges. Connect user google. Create objects and test data by running script googlemap/src/main/sql/create_tables_sdo.sql . Modify data source URL jdbc:oracle:thin:@localhost:1521:dev2 that is defined in file googlemap/src/main/webapp/META-INF/context.xml. Change the SID dev2 into you own SID.
If you have an older version of Oracle and you don’t have Locator installed as a separate option, you can still run this simple demo, by running the alternative script googlemap/src/main/sql/create_tables.sql. In this script the employee and customer data is geocoded in the most basic way by adding a Latitude and Longitude column to the tables. That works too in order to put data on a map (!), but of course you miss the rich geographic queries and related features – for instance asking the center of a collection of points and center the map accordingly, like is done in the example below.
If you want to add test data yourself, you’ll need to look for the latitudes and longitudes (don’t mix them up!). The Google documentation lists a number of free geocoders at http://www.google.com/search?q=free+geocoder.
Step 4.Â Â Â Prepare Tomcat
Install Tomcat 5.5 (http://tomcat.apache.org) and add the following jar files to CATALINA_HOME/common/lib:
Step 5.Â Â Â Get your Google Maps API key
Step 6.Â Â Â Launch the demo
Add directory .deployables under googlemap/. Import project into Eclipse (or other IDE). Run index.html on server. The map should appear right away. Congratulations!
The Google Maps API documentation is at http://www.google.com/apis/maps/documentation/#The_Basics. A tutorial is offered at http://www.econym.demon.co.uk/googlemaps.
- Spring and Oracle ADF – registering a POJO Spring JDBC based Business Service as Data Control
- Google Desktop Search – no more agonizing searches for lost documents
- Google api
- Spring MVC – move over Struts? Day two of the Spring Workshop
- Introducing Spring JDBC – frequently the best introduction of Spring in an organization
- Automatic deployment .ear file to Oracle Application Server 10.1.3 (OAS) with Ant tasks
- JDeveloper code templates
- Running Oracle Designer Generation from Ant and Hudson
- Hotsos Revisited 2013 – Presentatie materiaal
- ADF DVT Speed Date: Interactive Bubble Graph
- Oracle SQL – Finding free adjacent seats in an airplane, using Subquery Factoring, Analytical Functions (LISTAGG and LEAD), Outer Join, PIVOT and good old INSTR
- Oracle SQL – spotting combinations that occur and those that do not – demonstrating Analytical Functions, Outer Join and SubQuery Factoring
- How Oracle Database uses internal locks to make statement level constraint validation robust at the transaction level
- OTN Yathra 2013 – Spreading the story of Oracle across India – (Half time)
- Dear Java/JEE developer – why should you care about ADF?