filmov
tv
Populating a SQL Database in preparation for Java (Apache Derby)

Показать описание
In this video I will show how to populate a SQL database using Derby and then I will give a walkthrough of some basic SQL commands.
STEPS:
Open a new command prompt.
Check that your System Variables are set by typing in echo then the name of the variable you want to check bracketed by percentage signs. This is what I typed in and saw when my path variables were correctly set up:
echo %JAVA_HOME%
C:\Program Files\Java\jdk-20
echo %DERBY_HOME%
C:\Program Files\Java\jdk-20\db
echo %CLASSPATH%
If any of your System Variables are not correctly set up then you may need to either set them in Environment Variables and/or run setEmbeddedCP.bat which is found inside your Derby bin folder. Mine is located here: "C:\Program Files\Java\jdk-20\db\bin\setEmbeddedCP.bat"
Note that I will be using examples based on this textbook:
Java How to Program, Late Objects Version, Eleventh Edition, Paul Deitel & Harvey Deitel, Pearson, 2018, ISBN-13: 978-0-13-479140-1, ISBN-10: 0-13-479140-1
Next, connect to the Derby command prompt by typing the following command into your command prompt (INCLUDING the quotation marks) and hitting enter:
"%JAVA_HOME%\db\bin\ij"
Then type or copy in this command and hit enter to connect to, and create, a database named "books". You can name your database something else if you want. Note that this will also set up the database to use username "deitel" and password "deitel":
connect 'jdbc:derby:books;create=true;user=deitel;password=deitel';
(Note that if you've already created your books database then you connect without using create=true; so your connect command would just be this: connect 'jdbc:derby:books;user=deitel;password=deitel'; )
A bunch of SQL commands will scroll down the screen. At this point you can type in your own queries or updates. Put this one in to verify that you can access the correct data:
SELECT * FROM authors;
That's it. You're done.
Exit the Derby command prompt using these commands (note that the semicolons are needed):
disconnect; exit;