I am starting to put my hands on Java. Its quite amazing to see how Java connects to databases. Almost the same for all cases(tried Oracle,JavaDB). Just puting the code here to get in future.
Lets first start with creating and connecting to a JavaDB using netbeans.
first go to the services tab.
Expand the Database entry.
right click the JavaDB and click start server.
Right click again the JavaDB to create a new Database. The database create wizard shall appear.
Just type in the fields as indicated to continue this tutorial. the password is also "app".
connect to the newly created database. (right click and connect).
Expand the APP. and right click "Tables" to create a table. The table creator wizard appears.
Create your table using this wizard. When done Expand the Tables section to view your newly created table. You can add data to it if you want.