Java EE – GlassFish: name of driver class missing data source

(scroll to the end to find possible errors related to this.)

This connection pool seems to be correct, at least Ping is successful, but how is it actually referenced by the EJB module?

thufir@dur:~$
thufir@dur:~$glassfish-4.1/glassfish/bin/asadmin
Use "exit" to exit and "help" for online help.
asadmin> 
asadmin> list-jdbc-connection-pools
CLI031: Warning: Option "target" is obsolete and will be ignored.
CLI031: Warning: Option "target" is obsolete and will be ignored.
__TimerPool
DerbyPool
SamplePool
connectionPool
legacy_on_glassfish
Command list-jdbc-connection-pools executed successfully.
asadmin> 
asadmin> ping-connection-pool legacy_on_glassfish
Command ping-connection-pool executed successfully.
asadmin> 
asadmin> list-jdbc-resources
jdbc/sample
jdbc/__TimerPool
jdbc/__default
jdbc/local
jdbc/legacy_resource
Command list-jdbc-resources executed successfully.
asadmin>

(I don't know how to output JDBC connection properties with asadmin)

Use the NetBeans wizard, which is the generated persistence XML file:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="EnterpriseLegacyJDBC-ejbPU" transaction-type="JTA">
    <jta-data-source>jdbc/legacy_resource</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
      <property name="javax.persistence.schema-generation.database.action" value="create"/>
    </properties>
  </persistence-unit>
</persistence>

However, selecting new entity class from the database will result in:

From the GlassFish console, what is the name of the driver class of the data source?

Find it in the console. The data source class name is com MysqL. jdbc. jdbc2. optional. Mysqlconnectionpooldatasource, and the driver class name is not editable:

–––––––––––––––––––––––––––––––––-

https://netbeans.org/bugzilla/show_bug.cgi?id=238667#c19

However, I'm not sure what the datasource created using the GlassFish server administration console means - I just can't find the option

You can also see:

How to setup a JDBC connection in Glassfish

Solution

In the case of PostgreSQL, I encountered the same problem and performed the following steps to successfully connect to the database with netbean:

>Delete all connection pools and data sources you created from GlassFish using the administrative console > right click the project name in NetBeans. > Select new - > other - > GlassFish - > JDBC connection pool. > Click next. > Give pool name. > Select a new configuration using the database. > Select Postgres. > from the drop-down list In the next step, enter the following six parameters and their values:

>User – Postgres; > Databasename – (your database name); > ServerName – localhost; > PortNumber – 5432; > Password – (password for Postgres); > URL – jdbc:postgresql:// localhost:5432 / DBname

>Right click the project > select new - > other - > GlassFish - > JDBC resource. > Select use existing JDBC pool. > Select the pool name you created in the previous bullet. > Set asset name > click finish

Based on this resource, you can now create entities and the entire EJB resource without problems

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>