Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated.

Similar presentations


Presentation on theme: "Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated."— Presentation transcript:

1 Introduction to Derby

2 RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated into NetBeans! –No new installations –If you have NetBeans, you have Derby!

3 RHS – 2009 3 What is Derby…? We usually work with Java projects here… Now try the Services tab instead…

4 RHS – 2009 4 What is Derby…? Double-click to expand ”Databases”

5 RHS – 2009 5 What is Derby…? This is the GUI for creating and deleting databases in Derby From here, we can create a new database, which will be located on our own computer

6 RHS – 2009 6 Creating a database Right-click on ”Java DB”, and choose ”Create Database”

7 RHS – 2009 7 Creating a database

8 RHS – 2009 8 Creating a database Give the database a proper name

9 RHS – 2009 9 Creating a database Leave ”User Name” and ”Password” empty

10 RHS – 2009 10 Creating a database As default, database is located here… …but you can change the loca- tion yourself

11 RHS – 2009 11 Creating a database The (empty) database ”Friends” has been created

12 RHS – 2009 12 Creating a database This is all it takes to create a database in Derby! The database is located in the folder you have specified You can take a copy of the database, simply by taking a copy of the folder At first, the database is empty (of course)

13 RHS – 2009 13 Creating a database Can anything go wrong…? –Bad name (special characters are probably not allowed) –Delays (a pop-up saying ”…has not started in 5 seconds, do you want to wait longer?”) Just choose ”Yes” –Ask for help in case of problems!

14 RHS – 2009 14 Creating a database Exercise: 1.Create a database called ”PhoneBook”, using the Derby DBMS in NetBeans 2.After having created the database, see if you can find the folder which contains the database files 3.Now create a database called ”AddressBook”, but choose a different location for the database files than the default 4.Check that the files created for ”AddressBook” are located where you would expect them to be

15 RHS – 2009 15 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

16 RHS – 2009 16 Backing up a database Remember, that we specified the location when we created the database

17 RHS – 2009 17 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 right- clicking on the ”Java DB” icon, and choose ”Properties”

18 RHS – 2009 18 Backing up a database This is the general folder for storing databases

19 RHS – 2009 19 Backing up a database If you have a database called ”CarCata- log”, 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” data- base

20 RHS – 2009 20 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

21 RHS – 2009 21 Restoring a database Determine the folder used for databases on the computer: –This is done in same way as before, by right- clicking on the ”Java DB” icon, and choosing ”Properties” –Of course, this assumes that NetBeans and Java DB has been properly installed on the computer…

22 RHS – 2009 22 Restoring a database This is the general folder for storing databases

23 RHS – 2009 23 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

24 RHS – 2009 24 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…

25 RHS – 2009 25 Restoring a database

26 RHS – 2009 26 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

27 RHS – 2009 27 Restoring a database

28 RHS – 2009 28 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

29 RHS – 2009 29 Restoring a database Just press OK here…

30 RHS – 2009 30 Restoring a database The new connection has been established


Download ppt "Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated."

Similar presentations


Ads by Google