Thursday 27 December 2018

Adding MariaDB JDBC Connector to Paraya 5

It's as easy as pie.

  1. start Payara
    $ cd ~/payara5/bin
    $ ./asadmin start-domain
    Waiting for domain1 to start ...............
    Successfully started the domain : domain1
    domain Location: /home/mrbear/payara5/glassfish/domains/domain1
    Log File: /home/mrbear/payara5/glassfish/domains/domain1/logs/server.log
    Admin Port: 4848
    Command start-domain executed successfully.
  2. install the database driver
    $ ./asadmin add-library /home/mrbear/software/mariadb-java-client-2.3.0.jar
    Command add-library executed successfully.
    or try:
    $ cp ~/Downloads/mariadb-java-client-2.3.0.jar ~/payara5/glassfish/domains/domain1/lib

    The last part will probably require a payara application server reboot, though.

  3. connect to http://localhost:4848
  4. surf to Resources -> JDBC -> JDBC Connection Pools
  5. Create a new one
  6. Settings:
    Pool name[obvious]
    Resource Typejavax.sql.DataSource
    Datasource classnameorg.mariadb.jdbc.MariaDbDataSource

    Leave the rest as default.

  7. Define the following additional properties:
    NameValue
    serverNamelocalhost
    URLjdbc:mariadb://localhost:3306/mmud
    databaseNamemmud
    userusername
    passworditsasecret
  8. Try the "Ping" button to verify that the connection is established.
  9. surf to Resources -> JDBC -> JDBC Resources
  10. Create a new one
  11. Settings:
    NameValue
    JNDI Namethis is the name as the resource is defined in your application
    Pool Namethe pool defined previously, it's a dropdown which is convenient.
  12. Press finish or OK or something
  13. Done!

References

Using MySQL with Payara Server
https://blog.payara.fish/using-mysql-with-payara
Payara - Using Hibernate 5 on Payara Server
https://blog.payara.fish/using-hibernate-5-on-payara-server

No comments:

Post a Comment