introduction to derby. rhs – 2009 2 what is derby…? derby is a dbms –database –gui for...
TRANSCRIPT
![Page 1: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/1.jpg)
Introduction to Derby
![Page 2: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/2.jpg)
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!
![Page 3: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/3.jpg)
RHS – 2009 3
What is Derby…?
We usually work with Java projects here…
Now try the Services tab instead…
![Page 4: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/4.jpg)
RHS – 2009 4
What is Derby…?
Double-click to expand ”Databases”
![Page 5: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/5.jpg)
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
![Page 6: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/6.jpg)
RHS – 2009 6
Creating a database
Right-click on ”Java DB”, and choose ”Create Database”
![Page 7: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/7.jpg)
RHS – 2009 7
Creating a database
![Page 8: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/8.jpg)
RHS – 2009 8
Creating a database
Give the database a proper name
![Page 9: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/9.jpg)
RHS – 2009 9
Creating a database
Leave ”User Name” and ”Password” empty
![Page 10: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/10.jpg)
RHS – 2009 10
Creating a database
As default, database is located here…
…but you can change the loca-tion yourself
![Page 11: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/11.jpg)
RHS – 2009 11
Creating a database
The (empty) database ”Friends” has been created
![Page 12: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/12.jpg)
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)
![Page 13: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/13.jpg)
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!
![Page 14: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/14.jpg)
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
![Page 15: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/15.jpg)
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
![Page 16: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/16.jpg)
RHS – 2009 16
Backing up a database
Remember, that we specified the location when we created the database
![Page 17: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/17.jpg)
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”
![Page 18: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/18.jpg)
RHS – 2009 18
Backing up a database
This is the general folder for storing databases
![Page 19: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/19.jpg)
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
![Page 20: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/20.jpg)
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
![Page 21: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/21.jpg)
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…
![Page 22: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/22.jpg)
RHS – 2009 22
Restoring a database
This is the general folder for storing databases
![Page 23: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/23.jpg)
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
![Page 24: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/24.jpg)
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…
![Page 25: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/25.jpg)
RHS – 2009 25
Restoring a database
![Page 26: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/26.jpg)
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
![Page 27: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/27.jpg)
RHS – 2009 27
Restoring a database
![Page 28: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/28.jpg)
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
![Page 29: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/29.jpg)
RHS – 2009 29
Restoring a database
Just press OK here…
![Page 30: Introduction to Derby. RHS – 2009 2 What is Derby…? Derby is a DBMS –Database –GUI for administration –GUI for data maintenance Best part; integrated](https://reader035.vdocuments.net/reader035/viewer/2022062719/56649ef05503460f94c006c6/html5/thumbnails/30.jpg)
RHS – 2009 30
Restoring a database
The new connection has been established