In this chapter, we will create a copy of the report created in the previous chapter and modify it so that it takes its data from a relational source. We will explain what JDBC is, what a JDBC driver is, and how it is used.
The topics we will be covering in the chapter include the following:
As an extra, we will invite you to create your own report from the ground up, as well as give you a few tips to assist you in its creation.
Java Database Connectivity (JDBC) is an Application Programming Interface (API), which defines how a client should access and interact with a database from Java. Each provider (IBM, Oracle, Sun, Microsoft, and others) implements the mechanism (the "How To") for its own product, allowing the client not to be bothered with the details of each implementation and worrying only about its interface. In Java slang, this is known merely as a controller or JDBC driver.
In order for a JDBC driver to be used, Java programs require the following information:
java.sql.Driver
interface.In some cases, the inclusion of the user and password is supported within the URL, so we only need to define the URL and Driver parameters.
The syntax to indicate the URL and driver class name should always be present in the implementation documentation of each provider.
For example, in the case of MySQL, the information regarding the implementation can be found in the following web page:
http://dev.mysql.com/downloads/connector/j/5.1.html
The implementation details are as follows:
com.mysql.jdbc.Driver
jdbc:mysql://localhost:3306/MyDataBase
jdbc:mysql
localhost (local address)
3306 (default port)
MyDataBase