Derby db datasource creation. Classname not found

Hi all.
I have put derby client.jar into doman1/lib dir.
I createe the connectiom pool using the name of datasource implementatiin of derby.
Type: javax.Datasource

org.apache.derby.jdbc.ClientDataSource40

I added the properties of user, port, server, URL

locahost:1527/Sample
User app
Password app
Port 1527
Server localhost

But when i use the resource name for invece the datasource intoy server, i get into payara log that the class Is not found.

But the derby client.jar Is already present into domain1/lib.

I have triedany times but Is not working.
Mauro.

Greetings Mauro,

Here are the steps to set up a Derby JDBC connection pool and resource in the Payara Server.

  1. Place the Apache Derby DB driver derbyclient.jar in ${PAYARA_HOME}/glassfish/domains/domain1/lib.

  2. Restart the Payara Server after placing the jar.

  3. Create JDBC Connection pool by providing the following properties :

  • Pool Name : “DerbyTestPool”
  • Resource Type: “javax.sql.DataSource”
  • Database Driver Vendor: “Derby”
  • Datasource Classname : “org.apache.derby.jdbc.ClientDataSource40” or “org.apache.derby.jdbc.ClientDataSource” (Select or enter vendor-specific classname that implements the DataSource)

In the additional properties section, specify the user, password, portNumber, databaseName, serverName(Host name or IP address of the database server)

  1. Ping the pool to test the connection.

  2. Create a JDBC Resource (Resources → JDBC → JDBC Resources) by providing the JNDI Name (example - “jdbc/DerbyClient”) and pool name (“DerbyTestPool” or whatever you named it)

  3. You can now use this JDBC Resource in your application using
    @Resource(lookup = “jdbc/DerbyClient”)
    private DataSource ds;

Hope this helps!

Thanks & regards
Ramya

Yes It work. I added all.files of derby
Not only the derbyclient.jar and derbytools.jar .

Also the derbyshared.jar and other jars from derby lib.

I created the datasource into web.xml .

I used the web.xml from the payara example named datasource.

Now i have a problem with load Data from SQL file into META-INF.

Into persitence.xml
I added this property

<property name="jakarta.persistence.sql-load-script-source" value="META-INF/sql/data.sql" />.

When i deploy the war and start the web app the tables are created but the insert from the data.sql not worked. 

The tables are  empty. 
Please help me.

Do you have a  project working from GitHub ?

Mauro

Anither thing.
From log of payara server i read that the Entities not are weaved.

Greetings Mauro,

Glad to hear your Derby setup and JDBC datasource configuration are now working!

Now, lets try to address the other issue - data not being loaded from data.sql in META-INF.

You’re using this in your persistence.xml:


<property name="jakarta.persistence.sql-load-script-source" value="META-INF/sql/data.sql" />

Make sure data.sql is really inside the WAR file at META-INF/sql/data.sql. You can unzip the WAR to check.

Kindly check if its still present in the final WAR if you are using Maven or Gradle.

If the issue still persists, you can load the data manually using Java code at app startup.
Hope this helps!

Thanks & regards
Ramya