Вы находитесь на странице: 1из 17

Introduction to Derby

Backing up a database
At some point, you may wish to take a copy of your database, either for backup or for moving it to another computer Taking a backup is done simply by copying the folder in which the database is stored

Backing up a database

Remember, that we specified the location when we created the database


RHS 2009

Backing up a database
What if I have forgotten the location of the database? Databases are stored as subfolders to a general folder for databases This general folder can be found by rightclicking on the Java DB icon, and choose Properties

Backing up a database

This is the general folder for storing databases

RHS 2009

Backing up a database
If you have a database called CarCatalog, it will be located in a subfolder called CarCatalog, in the folder specified in the previous dialog Take a copy of the CarCatalog folder in order to back up your CarCatalog database

Restoring a database
Suppose now that I have a copy of a Derby database, and want to use that database on another computer We must perform these three steps:
Determine the folder used for databases on the computer Copy the folder containing the database copy into that folder Connect to the database
7

Restoring a database
Determine the folder used for databases on the computer:
This is done in same way as before, by rightclicking on the Java DB icon, and choosing Properties Of course, this assumes that NetBeans and Java DB has been properly installed on the computer

Restoring a database

This is the general folder for storing databases

Restoring a database
Copy the folder containing the database copy into that folder:
This is just a matter of simple file copying, from e.g a USB key into the general folder for storing databases

10

Restoring a database
Connect to the database:
Just copying the database folder is not enough to make it show up in the list of databases; we must connect to it Under the Databases icon, expand the Drivers tab Right-click on the Java DB (Network) icon, and choose Connect using A connect dialog will appear
11

Restoring a database

12

Restoring a database
In the connection dialog, we must supply the information needed to make a connection to the copied database
Host: localhost (since the database in on the computer itself) Port: 1527 (standard port used by Derby) Database: The exact name of the database User name & password: We usually leave these blank
13

Restoring a database

14

Restoring a database
If everything is in order, you will be taken to the advanced tab of the dialog when you press OK Here you just verify that the APP schema should be used in other words, just press OK again

15

Restoring a database

Just press OK here

16

Restoring a database

The new connection has been established

17

Вам также может понравиться