First get the terminology and the software right: Glassfish is a Java EE application server supporting under each JSP/Servlet. Eclipse is an IDE, just a development tool. None of them both are databases.
Thus, you actually need to install a separate database server next to them. There are five major DB vendors known at the world: MySQL, PostgreSQL, DB2, Microsoft SQL and Oracle. Just choose the one you like and/or can afford. On the other hand, you can also choose an embedded database, like JDK's built-in JavaDB.
Once done that, you need a JDBC driver to access either of them using Java code. A JDBC driver is basically a concrete implementation of the abstract JDBC API. Usually such a JDBC driver is already supplied by the DB vendor in question. Either included in the DB installation, or separately downloadable from their homepage. Just google "[dbvendorname] jdbc driver download" to get a download link/button.
In Eclipse, as being a development tool which already provides the Data Tools Platform (DTP) out of the box, you can manage databases and tables through the Data Source Explorer view (Window > Show View) and/or the Database Developer perspective.
Then you can just create Java classes which makes use of JDBC to execute the SQL. To learn about JDBC, consult Sun's JDBC tutorial. To go a step further, learn the DAO pattern how to abstract the one and other nicely away in a data access layer. Note: you still have to learn SQL separately. It is not part of JDBC, the JDBC is rougly said just a Java tool which enables executing the SQL language using Java code.
Once done that, you can just instantiate such a DAO class in a servlet class and use it during preprocessing and/or postprocessing the HTTP request. You normally don't want to do that in a JSP file. If you for example want to load a list from the database for display in a table, use servlet's doGet()
method in combination with RequestDispatcher#forward()
which forwards the request to a JSP for display. If you for example want to store a newly registered user in the database, use a <form method="post">
and the servlet's doPost()
method for this.
That said, you normally don't want to create/alter tables using Java/JDBC. You normally do that only once during application setup/installation and then use it forever. Use JDBC to select/insert/update the data in existing tables.