Database connectivity


We'll now write a class to check the database we've made.


Make yourself a new class in this project, called DBCheck, give it the attributes the previous class had when you made it, including a main method. Again, set it so the main method calls the constructor.


Now, in the constructor, write the code to do the following:

1) Import the derby driver.

2) Connect to the database without creating it.

3) Make a statement.

4) Execute the following statement using it: "SELECT Address,Burglaries FROM Results" and get back a ResultSet.

5) Loop through the ResultSet and System.out.println the results (note that you'll need getString for the Address and getInt for the Burglaries).

6) Close the connection.


Hopefully when you run that, you should see your table, as constructed by DBConnect. If you want something else to cut your teeth on, give it a go getting this lot working from within Arc, storing the results from last practical.