Tik-76.021 Ohjelmoinnin peruskurssi L2 Exercise 3

JDBC

Use your solution of exercise 2 for creating an application that reads the date/value data using JDBC instead of reading it from a text file. The resulting application should look like this (reference application included in the "Exc3Ref" directory):

Notice! The program in the image is written using the "Swing" user interface classes. Since the Swing exercise that was planned has been left out, you do not have to use Swing classes in this exercise!

In order to run the reference application and to make the exercise, you first have to add a new ODBC source as described in the course material. This ODBC source should have the name "Exc3Data", use a text driver and be connected to the directory "Exc3Data".

First add a method to the class "DateValueVector" that is declared like this:

public boolean getFromJDBC(String jdbcSource, String tableName, 
		String dateFieldName, String valueFieldName)

Have a look inside the files "schema.ini" and "Exc3Data" to find out what the values should be for these parameters. The return value of the method is true if successful and false if error.

Then add a method "public boolean getFromJDBC()" to the classes "DateValueGraphPanel" and "GraphCanvas". It should return true if successful and false otherwise. You can "hard-code" the JDBC source, table and field names in these methods.

Hints:

Remark: The reference solution was originally written for an exercise number 5 (not 3 like here), so if you have any difficulties in running the reference solution, then rename everything to Exc5Ref instead (also edit the file schema.ini).

To be returned: