GlassFish connection pool - mysql

i put mysql driver into glassfish/admin1/lib and i get this error on trying make a connection with GlassFish 3.1.2
Ping Connection Pool failed for SimpleCRUD_ConnectionPool. Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlDataSource Please check the server.log for more details.
Hare the configuration:
Pool Name: SimpleCRUD_ConnectionPool
Resource Type: javax.sql.DataSource javax.sql.XADataSource
Datasource Classname: com.mysql.jdbc.Driver
has someone any idea?

A Driver and a DataSource are not the same. It looks from your configuration that you're setting a Driver class as the DataSource classname?
Do you really need XA? Are you doing any distributed transaction?
If so, set the data source to com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
If not, select a regular DataSource type and then set the classname to com.mysql.jdbc.jdbc2.optional.MysqlDataSource

For starters, the path where you have placed your driver does not look correct. For details on administering database connectivity in Glassfish 3.1.2 please see
12 Administering Database Connectivity
Also in that guide you will find a section installing the MySQL Server Database Type 4 Driver
If you need additional help, please post a screen capture of your JDBC resource and JDBC connection pool configuration or if you used it the asadmin command you used to create it.
-Noah

No, you just lack mysql lib, just find and download mysql-connector-java-5.x.x-bin.jar copy to E:\Projects\glassfish3.1.1\glassfish\lib then restart server and enjoy !!!

Related

Azure Glassfish Connection Pooling Communications Link Failure

I have just set up a new Azure MySQL.
I can connect to it via Workbench but not via Glassfish 4.1.2 connection pool.
I am testing 2 installations of Glassfish. One on my machine (without SSL) another installation on another Azure VM (with SSL). But I get Communications Link Failure with every ping on both installations. While I can ping successfully via both installations to other MySQL on other machines.
I get my connection string from Azure portal.
All other GF connection pool configs are by default.
I have SSL certificate installed on Azure VM Glassfish.
I have allowed both ip addresses on azure portal (successful workbench connection).
Is there any documentation or tutorial on Azure MySQL + Glassfish Connection Pooling config?
I can't seem to find it. Or does anyone know what I'm missing? Please. Thank you.
I've solved the problem in case anyone is interested.
I'm using ConnectorJ v.5.5 which allows username character size max limit of 16. With Azure requiring us to append #servername at the end, it was over the limit.
So I switched to Connector v.8.0.22 which allows username max of 32 characters.
However, there are extra config. to avoid "Class name is wrong or classpath is not set" error
put the connector 8.0.22 in glassfish-4.1.2\glassfish4\glassfish\domains\domain1\lib
when setting connection pool set Datasource Classname = com.mysql.cj.jdbc.MysqlDataSource
in the properties change LoggerClassName = com.mysql.cj.log.StandardLogger and Logger = com.mysql.cj.log.StandardLogger
if you use SSL set useSSL=true otherwise set useSSL=false in the properties or connection string
cheers!

MySQL and Keycloak setup

Hello I am trying to add mysql database in my Keycloak server.
I've added module.xml and mysql-connector-java-5.1.42-bin.jar under /modules/system/layers/base/com/mysql/main.
When I am running the command to add mysql module,
./jboss-cli.sh, it errors out with
Exception in thread "CLI Terminal Connection (uninterruptable)"
java.lang.ArithmeticException: / by zero
And when i am trying to start Keycloak, I am also notified that there is a missing service.
service jboss.jdbc-driver.mysql (missing)
Please help!!
When I am running the command to add mysql module, ./jboss-cli.sh, it errors out with
Can you post your Command? You dont't have to do this with the cli. It's also possible to modify the config in a editor. At least for testing you should try this.
Keycloak docs have a pretty good part about database setup: https://www.keycloak.org/docs/latest/server_installation/index.html#_database
The basic steps are:
Locate and download a JDBC driver for your database
Package the driver JAR into a module and install this module into the server (module.xml)
Declare the JDBC driver in the configuration profile of the server (standalone.xml)
Modify the datasource configuration to use your database’s JDBC driver
Modify the datasource configuration to define the connection parameters to your database
There is an error in the Keycloak documentation. Driver should be in the
modules/system/layers/base/com/mysql/driver/main
folder.
The full valid instruction is here
https://github.com/v-ladynev/keycloak-nodejs-example#keycloak-configuration
Also you can use docker images to experiment
https://github.com/v-ladynev/keycloak-nodejs-example#keycloak-docker-image

How to connect jmeter with database by using mysql-connector-java?

I am using phpMyAdmin version 5.7.15 and database mysql-connector-java version 5.1.40, but I am unable to connect the database with jmeter3.0. Could you please advise?
Add your driver in jmeter/lib folder
Then add a JDBC Connection Configuration and fill in:
Database URL: https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration-properties.html
JDBC Driver class: com.mysql.jdbc.Driver
login and password
Variable Name will identify the connection
Then add a JDBC Request under a Thread Group
and fill in:
Variable Name : same value as the one in JDBC Connection Configuration
The other fields which depend on what you want to do
Read this tutorial:
https://jmeter.apache.org/usermanual/build-db-test-plan.html
If you're looking to learn jmeter correctly, this book will help you.

wso2 manager - com.mysql.jdbc.Driver not found

I've downloaded WSO2 Stratos 1.5.2 platform.
I'm trying to start wso2stratos-manager-1.5.2, but it doesn't find the mysql jdbc driver
[2012-08-08 16:31:15,201] ERROR
{org.wso2.carbon.user.core.util.DatabaseUtil} - Database Error -
Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver
class 'com.mysql.jdbc.Driver'
I believe you're trying to use a mysql database as the backend database of the user management repository. Did you put the MySQL JDBC driver to MANAGER_HOME/repository/components/lib directory?
Regards,
Prabath
We do not ship the mysql-connector jar with our packs due to license issues. Therefore you need to copy the jar to repository/components/lib folder as mentioned in Prabath's reply.
Regards,
Amila.
As mentioned by others but adding specific details.
When configuring the Datasource Driver in many of the WSO2 products you need to specify the class name of the JDBC driver to use.
Make sure to copy the JDBC driver relevant to the database engine to the /repository/components/lib/ directory.
For example, if you are using MySQL, specify com.mysql.jdbc.Driver as the driver and copy mysql-connector-java-5.XX-bin.jar file to this directory.
If you do not copy the driver to this directory when you create the datasource, you will get an exception similar to Cannot load JDBC driver class com.mysql.jdbc.Driver.
Driver name is "com.mysql.jdbc.Driver".
JAR file (mysql-connector-java-x.xx.xx.jar) must be present in MANAGER_HOME/repository/components/lib
I solved by adding the mysql jar file at the directory
C:\Program Files\WSO2\Identity Server\6.1.0\repository\components\lib
You can download jar by the following link:
https://mvnrepository.com/artifact/mysql/mysql-connector-java/8.0.20
After that you should restart the WSO2 server

GlassFish not loading connector

I'm using GlassFish 3 and I can't seem to get it to recognize the MySql connector. The admin console always says:
Ping Connection Pool for --- is
Failed. Ping failed Exception - Class
name is wrong or classpath is not set
for :
com.mysql.jdbc.jdbc2.optional.MysqlDataSource
Please check the server.log for more
details.
However, JPA can connect even with the error. The only downside is that I get resize pool exceptions (null). I've even placed the connector in the following folders:
%GLASSFISH%/lib
%GLASSFISH%/domains/domain1/lib
%GLASSFISH%/domains/domain1/lib/ext
I also tried the solution at http://old.nabble.com/MySql-connector-problems,-Class-name-is-wrong-or-classpath-td21833176.html however setting class path is (unsupported in V3).
Any ideas? :(
EDIT:
Nvm... I fixed it by dropping the connector in
eclipse/plugins/oracle.eclipse.runtime.glassfish_3.1.0.0/glassfish3/glassfish/lib