Your questions are relevant. I agree, it is hard to find quality information on the web. Maybe we need Googleplex, not just Google ;).
The point of coffeebreak tutorial is to be able to run a simple Java class(es) to demonstrate use
of JDBC API to access/modify the relational database tables (or the data therein).
If you want to do that in a web application setting (which is why you use GlassFish anyway),
the basic premise does not change. You need a database with the schema for the tables
(and the tables) defined. GlassFish being a server assumes that you have that database,
unless you use some options on deployment operation.
The way GlassFish server communicates with Database server is through connection pools.
You don't have to use them if you want to try out JDBC API and hard-code DDL statements
like "select * from ... where ..." in your servlet code.
So, in essence, you can just do the following:
- choose a database vendor of choice (Java DB/MySQL).
- "create" a database, with an intent to "use" it.
- create the set of tables symbolizing entities and relations in coffeebreak sample -- this is
typically done using SQL scripts.
- add the code to access/modify the tables to servlet.
That's the first step. Make sure you see all changes reflected in the database.
Now, to do it the "correct way" you need to define external resources (jdbc resource in
this case), so that you can change the resource end points (e.g. db1 -> db2) without changing
your servlet code, then you need to define jdbc-connection-pool and jdbc-resource and
then "look up" that resource from within servlet code.
[Message sent by forum member 'km' (km)]
http://forums.java.net/jive/thread.jspa?messageID=285058