Configure the glassfish server in netbeans

Source: Internet
Author: User
Tags glassfish netbeans

Configure the glassfish server in netbeans

 

1. Start the glassfish server and enter http: // localhost: 4848/in the address bar to enter the server configuration interface, as shown below:

 

2. Select JDBC of resources under common tasks. The JDBC resources and connection pools are displayed as follows:

 

3. Click the new button in the connection pool to create a connection pool jdbc_test, as shown below:

 

Click Next, as shown below:


Keep other parameter configurations by default. Click finsh.

Click jdbc_test to display the following configuration interface:


Set the parameters on the general and advanced interfaces by default. Click

Additionalproperties (other properties) to enter the configuration interface:


Click Add property)

Portnumber 3306

Driverclass com. MySQL. JDBC. Driver

Zerodatetimebehavior converttonull

Databasename db_test

User Root

Url jdbc: mysql: // 127.0.0.1: 3306/db_test

Servername 127.0.0.0

Password Admin

Transformedbitlsboolean true

 

4. After configuration, go to the general (general) configuration page and click the ping button. If the following page appears, the connection pool is successfully created.

 

NOTE: If javax. resource. resourceexception: Class Name Is Wrong orclasspath is not set for: COM. mySQL. JDBC. jdbc2.optional. mysqldatasource this error is because the MySQL driver package mysql-connector-java-5.1.20-bin.jar is not placed in the glassfish installation directory Domains \ domain1 \ Lib \ ext;

Solution: Put the MySQL driver package mysql-connector-java-5.1.20-bin.jar under the glassfish installation directory Domains \ domain1 \ Lib \ ext and restart the glassfish server.


5. After the connection pool is successfully created, click JDBC resources. On the JDBC resource configuration page, the pool name (connection pool name) displays the jdbc_test connection pool that has just been configured. The configuration interface is as follows:

 

6. On the configuration page, configure the JNDI name JDBC/test (this name can be obtained by yourself). Now, the connection pool and data source are configured.


7. test whether the data source is successfully connected:

Create a project in netbeans and use Java
Web category. The code for selecting index. jsp of a Web application is as follows:

<% @ Pagecontenttype = "text/html" pageencoding = "UTF-8" %> <% @ pageimport = "javax. naming. * "%> <% @ pageimport =" javax. SQL. * "%> <% @ pageimport =" Java. SQL. * "%> <HTML> 

8. Run the project directly. If the following interface is displayed, the project runs successfully.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.