In order to connect to the database, you need to define a JDBC connection pool and JDBC resource using the GlassFish Admin Console or the command-line interface.
Start the GlassFish server.
To create the connection pool and JDBC resource, follow the instructions under Creating a JDBC Connection Pool in Sun GlassFish Enterprise Server 2.1 Administration Guide.
Use the information from the database connection you created earlier in To Create and Connect to the Database.