Skip to main content

What are GF requirements for creating JDBC connection pool with MySQL?

20 replies [Last post]
ajeh
Offline
Joined: 2013-10-01
Points: 0

I was told elsewhere that for that to work I had to drop

mysql-connector-java-5.1.26-bin.jar

into

glassfish/domains/domain1/lib/ext

directory under GF install. So I did and got this error upon creation of the pool:

Pool successfully created with the following Warning

Ping Connection Pool failed for blanketBuilderDBPool.
Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
Please check the server.log for more details.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kjbaxter
Offline
Joined: 2008-10-21
Points: 0
ajeh
Offline
Joined: 2013-10-01
Points: 0

Ain't not working.
I've tried putting ConnectorJ under both lib and lib/ext and still ping fails with exact same error.

kjbaxter wrote:
Please check these articles:

http://netbeans.dzone.com/connection-pooling-glassfish-nb

http://yp-javadev.blogspot.com/2013/07/resolved-ping-connection-pool-fai...

Hope it helps.

emailnbw
Offline
Joined: 2008-05-28
Points: 0

The Oracle documentation is also helpful in this regard. Please see Section 12 of [1].

-Noah

[1] - https://glassfish.java.net/docs/4.0/administration-guide.pdf

On Oct 1, 2013, at 11:27 PM, forums@java.net wrote:

> Please check these articles:
> http://netbeans.dzone.com/connection-pooling-glassfish-nb
> http://yp-javadev.blogspot.com/2013/07/resolved-ping-connection-pool-fai...
> Hope it helps.
>
> --
>
> [Message sent by forum member 'kjbaxter']
>
> View Post: http://forums.java.net/node/899077
>
>

ajeh
Offline
Joined: 2013-10-01
Points: 0

The document you've linked lacked important specifics, such as where MySQL .jar should reside. Yes, it mentioned that .jar by name, and the [intuitive] properties for it, but it did not solve the problem.

emailnbw wrote:
The Oracle documentation is also helpful in this regard. Please see Section 12 of [1].

-Noah

[1] - https://glassfish.java.net/docs/4.0/administration-guide.pdf

On Oct 1, 2013, at 11:27 PM, forums@java.net wrote:

> Please check these articles:
> http://netbeans.dzone.com/connection-pooling-glassfish-nb
> http://yp-javadev.blogspot.com/2013/07/resolved-ping-connection-pool-fai...
> Hope it helps.
>
> --
>
> [Message sent by forum member 'kjbaxter']
>
> View Post: http://forums.java.net/node/899077
>
>

emailnbw
Offline
Joined: 2008-05-28
Points: 0

Actually it does mention these details. Take a look at Chapter 12, there's a section on the steps needed to setup the Database including how to install the driver.

If you are new to Glassfish you will find a lot if useful information in that document, skim over the table of contents.

-Noah

Sent from my iPhone

> On Oct 2, 2013, at 12:49 PM, forums@java.net wrote:
>
> The document you've linked lacked important specifics, such as where MySQL
> .jar should reside. Yes, it mentioned that .jar by name, and the [intuitive]
> properties for it, but it did not solve the problem.

emailnbw wrote:
The
> Oracle documentation is also helpful in this regard. Please see Section 12 of
> [1]. -Noah [1] - https://glassfish.java.net/docs/4.0/administration-guide.pdf
> On Oct 1, 2013, at 11:27 PM, forums@java.net wrote: > Please check these
> articles: > http://netbeans.dzone.com/connection-pooling-glassfish-nb >
> http://yp-javadev.blogspot.com/2013/07/resolved-ping-connection-pool-fai...
> > Hope it helps. > > -- > > [Message sent by forum member 'kjbaxter'] > >
> View Post: http://forums.java.net/node/899077 > >

>
> --
>
> [Message sent by forum member 'ajeh']
>
> View Post: http://forums.java.net/node/899077
>
>

ajeh
Offline
Joined: 2013-10-01
Points: 0

Irregardless of where I dropped ConnectorJ - in lib or in lib/ext or in both, ping does not work for the same reason 'Class name is wrong or classpath is not set'.

The only logical hypothesis could be that I am not in the correct domain directory. How can I determine for certain what is my domain directory location?

emailnbw wrote:
Actually it does mention these details. Take a look at Chapter 12, there's a section on the steps needed to setup the Database including how to install the driver.

If you are new to Glassfish you will find a lot if useful information in that document, skim over the table of contents.

-Noah

Sent from my iPhone

> On Oct 2, 2013, at 12:49 PM, forums@java.net wrote:
>
> The document you've linked lacked important specifics, such as where MySQL
> .jar should reside. Yes, it mentioned that .jar by name, and the [intuitive]
> properties for it, but it did not solve the problem.

emailnbw wrote:
The
> Oracle documentation is also helpful in this regard. Please see Section 12 of
> [1]. -Noah [1] - https://glassfish.java.net/docs/4.0/administration-guide.pdf
> On Oct 1, 2013, at 11:27 PM, forums@java.net wrote: > Please check these
> articles: > http://netbeans.dzone.com/connection-pooling-glassfish-nb >
> http://yp-javadev.blogspot.com/2013/07/resolved-ping-connection-pool-fai...
> > Hope it helps. > > -- > > [Message sent by forum member 'kjbaxter'] > >
> View Post: http://forums.java.net/node/899077 > >

>
> --
>
> [Message sent by forum member 'ajeh']
>
> View Post: http://forums.java.net/node/899077
>
>

emailnbw
Offline
Joined: 2008-05-28
Points: 0

The domain name is part of the path. For example $GF_HOME/glassfish/domains/domain1 is the domain1 root.

$GF_HOME/glassfish/domains/foo would be the domain root to a domain named foo.

If you are working with the default domain, that is domain1, you would drop the driver JAR into $GF_HOME/glassfish/domains/domain1/lib and restart domain1 with asadmin like so:

$GF_HOME/glassfish/bin/asadmin restart-domain domain1

After the domain restarts you should try logging into the admin console to try your ping - you need to restart the domain after dropping the driver jar into the directory so it picks it up. If you are using the default domain1 the admin console will be on port 4848.

-Noah

On Oct 2, 2013, at 7:33 PM, forums@java.net wrote:

> Irregardless of where I dropped ConnectorJ - in lib or in lib/ext or in both,
> ping does not work for the same reason 'Class name is wrong or classpath is
> not set'. The only logical hypothesis could be that I am not in the correct
> domain directory. How can I determine for certain what is my domain directory
> location?

emailnbw wrote:
Actually it does mention these details. Take a look
> at Chapter 12, there's a section on the steps needed to setup the Database
> including how to install the driver. If you are new to Glassfish you will
> find a lot if useful information in that document, skim over the table of
> contents. -Noah Sent from my iPhone > On Oct 2, 2013, at 12:49 PM,
> forums@java.net wrote: > > The document you've linked lacked important
> specifics, such as where MySQL > .jar should reside. Yes, it mentioned that
> .jar by name, and the [intuitive] > properties for it, but it did not solve
> the problem.
emailnbw wrote:
The > Oracle documentation is also helpful in
> this regard. Please see Section 12 of > [1]. -Noah [1] -
> https://glassfish.java.net/docs/4.0/administration-guide.pdf > On Oct 1,
> 2013, at 11:27 PM, forums@java.net wrote: > Please check these > articles: >
> http://netbeans.dzone.com/connection-pooling-glassfish-nb > >
> http://yp-javadev.blogspot.com/2013/07/resolved-ping-connection-pool-fai...
> > > Hope it helps. > > -- > > [Message sent by forum member 'kjbaxter'] > > >
> View Post: http://forums.java.net/node/899077 > >
> > -- > > [Message
> sent by forum member 'ajeh'] > > View Post:
> http://forums.java.net/node/899077 > >

>
> --
>
> [Message sent by forum member 'ajeh']
>
> View Post: http://forums.java.net/node/899077
>
>

ajeh
Offline
Joined: 2013-10-01
Points: 0

That's where the jar is: $GF_HOME/glassfish/domains/domain1/lib
Not working. No log.

Tested under Win7. There is one visible difference: there are already derby.jar and derbyclient.jar under domains/domain1/lib.

Once I dropped ConnectorJ in there and restarted domain, ping worked. What is different under Fedora then, that derby jars are not in the domain1 and mysql jar does not work there?

The only idea I have is that domain1 created by the installer.sh is not the domain1 used by the server. How can I find out exactly which domain1 folder GF server is using?

emailnbw wrote:
The domain name is part of the path. For example $GF_HOME/glassfish/domains/domain1 is the domain1 root.

$GF_HOME/glassfish/domains/foo would be the domain root to a domain named foo.

If you are working with the default domain, that is domain1, you would drop the driver JAR into $GF_HOME/glassfish/domains/domain1/lib and restart domain1 with asadmin like so:

emailnbw
Offline
Joined: 2008-05-28
Points: 0

You have absolutely no server.log file?

On Oct 3, 2013, at 10:03 AM, forums@java.net wrote:

> That's where the jar is: $GF_HOME/glassfish/domains/domain1/lib Not working.
> No log.

emailnbw wrote:
The domain name is part of the path. For example
> $GF_HOME/glassfish/domains/domain1 is the domain1 root.
> $GF_HOME/glassfish/domains/foo would be the domain root to a domain named
> foo. If you are working with the default domain, that is domain1, you would
> drop the driver JAR into $GF_HOME/glassfish/domains/domain1/lib and restart
> domain1 with asadmin like so:

>
> --
>
> [Message sent by forum member 'ajeh']
>
> View Post: http://forums.java.net/node/899077
>
>

ajeh
Offline
Joined: 2013-10-01
Points: 0

log under domain1 is pristine clean.
Since I first installed Netbeans, domain log popup menu item on Glassfish server never worked.
I probably will have to resort to searching for another directory where GF may keep default domain.
Why does this have to be so confusing and counter-intuitive is beyond me.
First NB and GF require to be installed into root owned directory, then this...

emailnbw wrote:
You have absolutely no server.log file?

emailnbw
Offline
Joined: 2008-05-28
Points: 0

Honestly, its not really this complicated. I personally don't use Netbeans so I can't speak to that. Can you try simply downloading the GF4 zip distribution from [1]. Then unzip it to a directory, drop the DB driver jar into place, and start up the domain using the asadmin start-domain cmd? That will rule out issues you might be having with your Netbeans environment.

-Noah

[1] - https://glassfish.java.net/download.html

On Oct 3, 2013, at 3:35 PM, forums@java.net wrote:

> log under domain1 is pristine clean. Since I first installed Netbeans, domain
> log popup menu item on Glassfish server never worked. I probably will have to
> resort to searching for another directory where GF may keep default domain.
> Why does this have to be so confusing and counter-intuitive is beyond me.
> First NB and GF require to be installed into root owned directory, then
> this...

emailnbw wrote:
You have absolutely no server.log file?

>
> --
>
> [Message sent by forum member 'ajeh']
>
> View Post: http://forums.java.net/node/899077
>
>

ajeh
Offline
Joined: 2013-10-01
Points: 0

Finally! This is what's happening.
When I installed Netbeans 7.3.1, it came with Glassfish 3 which installed within Netbeans directory tree and created its own domain1 underneath.
Netbeans 7.4rc1 which I am using for development of web projects only (which simply don't work under 7.3.1) came with Netbeans 4 which installed into its own directory and created its own domain1 underneath.
But Glassfish 4 did not use its own domain1. It quietly re-used domain1 of Glassfish 3.

emailnbw wrote:
Honestly, its not really this complicated. I personally don't use Netbeans so I can't speak to that. Can you try simply downloading the GF4 zip distribution from [1]. Then unzip it to a directory, drop the DB driver jar into place, and start up the domain using the asadmin start-domain cmd? That will rule out issues you might be having with your Netbeans environment.

-Noah

[1] - https://glassfish.java.net/download.html

On Oct 3, 2013, at 3:35 PM, forums@java.net wrote:

> log under domain1 is pristine clean. Since I first installed Netbeans, domain
> log popup menu item on Glassfish server never worked. I probably will have to
> resort to searching for another directory where GF may keep default domain.
> Why does this have to be so confusing and counter-intuitive is beyond me.
> First NB and GF require to be installed into root owned directory, then
> this...

emailnbw wrote:
You have absolutely no server.log file?

>

ajeh
Offline
Joined: 2013-10-01
Points: 0

New error:

Ping Connection Pool failed for blanketBuilderDBPool. Connection could not be allocated because: Access denied for user 'jdbcGB'@'localhost' (using password: YES) Please check the server.log for more details.

GF is appending @'localhost' to the user name and that fails the logins.
What now?

emailnbw
Offline
Joined: 2008-05-28
Points: 0

It sounds like your connection pool properties are misconfigured for your
environment or you haven't got MySQL setup correctly.

Have you created the DB with the correct user and password in MySQL prior
to pinging it from the connection pool? Can you access the DB using that
user name and password from the mysql cmd line tool from the mysql distro?

If you can get that far check your connection pool properties to make sure
they are also in good shape.

Those are in the In the "Additional properties" tab of the JDBC Connection
Pools area in the admin GUI for your blankeyBuilderDBPool.

Also, if you open $GF_HOME/glassfish/domains1/domain1/config/domain.xml and
find the with the pool-name attr of your pool and the
with the name attr of the associated jdbc-resource
and copy/paste them to the list and we can help verify your settings.

-Noah

On Sat, Oct 5, 2013 at 9:22 AM, wrote:

> New error: Ping Connection Pool failed for blanketBuilderDBPool. Connection
> could not be allocated because: Access denied for user 'jdbcGB'@
> 'localhost'
> (using password: YES) Please check the server.log for more details. GF is
> appending @'localhost' to the user name and that fails the logins. What
> now?
>
>
> --
>
> [Message sent by forum member 'ajeh']
>
> View Post: http://forums.java.net/node/**899077
>
>
>

ajeh
Offline
Joined: 2013-10-01
Points: 0

Thank you for considering me a complete idiot who does not understand that database name, user and password have to be valid.

This gives me ping error:

An error has occurred Ping Connection Pool failed for blanketBuilderDBPool. Connection could not be allocated because: Access denied for user 'jdbcGF'@'localhost' (using password: YES) Please check the server.log for more details. An error has occurred
Ping Connection Pool failed for blanketBuilderDBPool. Connection could not be allocated because: Access denied for user 'jdbcGF'@'localhost' (using password: YES) Please check the server.log for more details.

Now if we connected with the same parameters on the command line, they would work fine.

$ mysql --host=10.10.10.2 --user=jdbcGF --password=jdbc
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 31234
Server version: 5.5.8 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select * from test.color;
+----------+----------+-----+-------+------+
| color_id | color | red | green | blue |
+----------+----------+-----+-------+------+
| 1 | White | 255 | 255 | 255 |
| 2 | Yellow | 255 | 255 | 0 |
| 3 | Pink | 250 | 105 | 180 |
| 4 | Red | 255 | 0 | 0 |
+----------+----------+-----+-------+------+
4 rows in set (0.00 sec)

mysql>

So how does it sound now?

emailnbw wrote:
It sounds like your connection pool properties are misconfigured for your
environment or you haven't got MySQL setup correctly.

Have you created the DB with the correct user and password in MySQL prior
to pinging it from the connection pool? Can you access the DB using that
user name and password from the mysql cmd line tool from the mysql distro?

If you can get that far check your connection pool properties to make sure
they are also in good shape.

Those are in the In the "Additional properties" tab of the JDBC Connection
Pools area in the admin GUI for your blankeyBuilderDBPool.

Also, if you open $GF_HOME/glassfish/domains1/domain1/config/domain.xml and
find the with the pool-name attr of your pool and the
with the name attr of the associated jdbc-resource
and copy/paste them to the list and we can help verify your settings.

-Noah

On Sat, Oct 5, 2013 at 9:22 AM, wrote:

> New error: Ping Connection Pool failed for blanketBuilderDBPool. Connection
> could not be allocated because: Access denied for user 'jdbcGB'@
> 'localhost'
> (using password: YES) Please check the server.log for more details. GF is
> appending @'localhost' to the user name and that fails the logins. What
> now?
>
>
> --
>
> [Message sent by forum member 'ajeh']
>
> View Post: http://forums.java.net/node/**899077
>
>
>

emailnbw
Offline
Joined: 2008-05-28
Points: 0

My environment is Mac OS X 10.8.5 w/Oracle JDK 1.8.0-EA-b109 and to test this out I just downloaded the GF 4.0 ZIP distribution (promoted build 3 but you could grab any I'm sure), and MySQL 5.6.14 64bit DMG (Mac OS X) and unzipped GF into my home directory and ran the MySQL installer from the DMG.

I connected to MySQL w/the cmd line tool and created a test db like so:

mysql> create database test2;
Query OK, 1 row affected (0.00 sec)

mysql> grant usage on *.* to jdbcGF@localhost identified by 'jdbc';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on test2.* to jdbcGF@localhost;
Query OK, 0 rows affected (0.00 sec)

mysql> exit

Then I downloaded the MySQL connector/J JDBC driver (5.1.26), unzipped it and placed the driver JAR into domains/domain1/lib.

Then I started domain1 from a terminal app: ./asadmin start-domain

Then I went and created a JDBC Connection pool in the admin GUI with the following configuration:

Pool name: BuilderDBPool
Resource Type: javax.sql.DataSource
Database vendor: MySQL
(clicked Next button)

Under additional properties (and there were a lot) I set the following:

URL and Url to:
jdbc:mysql://localhost:3306/test2

Password: jdbc
User: jdbcGF

That's all, I left everything else alone.

I clicked Finish and the did a ping and it worked just fine. This whole process took less then 5 minutes (took longer to type this).

Looking at your domain.xml I see your URL string is wrong. The last part is the DB name so change it to:

jdbc:mysql://localhost:3306/test

See the docs here [2] for details on the driver configuration properties.

My domain.xml jdbc-connection-pool also came out a lot longer then yours (which GF version are you using, which Connector J version are you using?). If you want to compare I pasted it here [3].

And FWIW this isn't my forum, I'm just another GF user like you trying to lend you a hand. I agree that the forum software sucks (as does java.net). For example, it's nearly impossible for me to read your posts since the forum software mangles them when they are mirrored into the gf users mailing list that I am reading them from.

-Noah

[1] - http://www.catb.org/esr/faqs/smart-questions.html#beprecise
[2] - http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configurati...
[3] - http://pastebin.com/jQzga2f7

On Oct 5, 2013, at 6:40 PM, forums@java.net wrote:

> Thank you for considering me a complete idiot who does not understand that
> database name, user and password have to be valid. This gives me ping error:
> An error has occurred Ping Connection Pool failed for blanketBuilderDBPool.
> Connection could not be allocated because: Access denied for user
> 'jdbcGF'@'localhost' (using password: YES) Please check the server.log for
> more details. An error has occurred Ping Connection Pool failed for
> blanketBuilderDBPool. Connection could not be allocated because: Access
> denied for user 'jdbcGF'@'localhost' (using password: YES) Please check the
> server.log for more details. Now if we connected with the same parameters on
> the command line, they would work fine. $ mysql --host=10.10.10.2
> --user=jdbcGF --password=jdbc Welcome to the MySQL monitor. Commands end with
> ; or \g. Your MySQL connection id is 31234 Server version: 5.5.8 MySQL
> Community Server (GPL) Copyright (c) 2000, 2011, Oracle and/or its
> affiliates. All rights reserved. Oracle is a registered trademark of Oracle
> Corporation and/or its affiliates. Other names may be trademarks of their
> respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the
> current input statement. mysql> use test Reading table information for
> completion of table and column names You can turn off this feature to get a
> quicker startup with -A Database changed mysql> select * from test.color;

ajeh
Offline
Joined: 2013-10-01
Points: 0

Before asking me to paste XML, make sure that your forum software will display it.

ajeh wrote:
Thank you for considering me a complete idiot who does not understand that database name, user and password have to be valid.

This gives me ping error:

An error has occurred Ping Connection Pool failed for blanketBuilderDBPool. Connection could not be allocated because: Access denied for user 'jdbcGF'@'localhost' (using password: YES) Please check the server.log for more details. An error has occurred
Ping Connection Pool failed for blanketBuilderDBPool. Connection could not be allocated because: Access denied for user 'jdbcGF'@'localhost' (using password: YES) Please check the server.log for more details.

Now if we connected with the same parameters on the command line, they would work fine.

$ mysql --host=10.10.10.2 --user=jdbcGF --password=jdbc
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 31234
Server version: 5.5.8 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select * from test.color;
+----------+----------+-----+-------+------+
| color_id | color | red | green | blue |
+----------+----------+-----+-------+------+
| 1 | White | 255 | 255 | 255 |
| 2 | Yellow | 255 | 255 | 0 |
| 3 | Pink | 250 | 105 | 180 |
| 4 | Red | 255 | 0 | 0 |
+----------+----------+-----+-------+------+
4 rows in set (0.00 sec)

mysql>

So how does it sound now?

emailnbw wrote:
It sounds like your connection pool properties are misconfigured for your
environment or you haven't got MySQL setup correctly.

Have you created the DB with the correct user and password in MySQL prior
to pinging it from the connection pool? Can you access the DB using that
user name and password from the mysql cmd line tool from the mysql distro?

If you can get that far check your connection pool properties to make sure
they are also in good shape.

Those are in the In the "Additional properties" tab of the JDBC Connection
Pools area in the admin GUI for your blankeyBuilderDBPool.

Also, if you open $GF_HOME/glassfish/domains1/domain1/config/domain.xml and
find the with the pool-name attr of your pool and the
with the name attr of the associated jdbc-resource
and copy/paste them to the list and we can help verify your settings.

-Noah

On Sat, Oct 5, 2013 at 9:22 AM, wrote:

> New error: Ping Connection Pool failed for blanketBuilderDBPool. Connection
> could not be allocated because: Access denied for user 'jdbcGB'@
> 'localhost'
> (using password: YES) Please check the server.log for more details. GF is
> appending @'localhost' to the user name and that fails the logins. What
> now?
>
>
> --
>
> [Message sent by forum member 'ajeh']
>
> View Post: http://forums.java.net/node/**899077
>
>
>

jdlee
Offline
Joined: 2006-01-25
Points: 0

In the URL property, try changing localhost to the IP you have under serverName.

ajeh
Offline
Joined: 2013-10-01
Points: 0

That did it. Or I can delete URL property completely. Either works. It was overriding the other properties.

jdlee wrote:
In the URL property, try changing localhost to the IP you have under serverName.

jdlee
Offline
Joined: 2006-01-25
Points: 0

Awesome! Sorry that took so long, but I'm glad you're working. :)