File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Glassfish and the fly likes GlassFish Server does not connect to SQL database (problem with SQL driver) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Glassfish
Bookmark "GlassFish Server does not connect to SQL database (problem with SQL driver)" Watch "GlassFish Server does not connect to SQL database (problem with SQL driver)" New topic
Author

GlassFish Server does not connect to SQL database (problem with SQL driver)

Heinz Uller
Greenhorn

Joined: Jun 06, 2013
Posts: 8
Dear all,

I am using a brand new developing pc and need to test a personal application that runs on a local GlassFish server 3.1.2 and should connect with a local SQL database called 'funkOneDB' (my IDE is NetBeans 7.2.1). But I can't get the GlassFish server to connect with the database (problem specifics in a few lines).

I am fairly certain I correctly set up the related JDBC Resource and Connection Pool on the GlassFish Server (as I mimic a set-up already existing and working properly on another developing pc).

The Resource specifics are:
  • jndi name: jdbc/FunkResource
  • pool name: FunkPool

  • The (most important) Pool specifics are:
  • pool name: FunkPool
  • resource type: javax.sql.Datasource
  • datasource classname: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
  • additional properties correspond to the specifics in the XML GlassFish-resources of the application, namely:

  • <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://GlassFish.org/dtds/GlassFish-resources_1_5.dtd">
    <resources>
    <jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="FunkPool" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
    <property name="serverName" value="localhost"/>
    <property name="portNumber" value="33066"/>
    <property name="databaseName" value="funkOneDB"/>
    <property name="User" value="[USERNAME]"/>
    <property name="Password" value="[PASSWORD]"/>
    <property name="URL" value="jdbc:mysql://localhost:33066/funkOneDB"/>
    <property name="driverClass" value="com.mysql.jdbc.Driver"/>
    </jdbc-connection-pool>
    <jdbc-resource enabled="true" jndi-name="jdbc/FunkResource" object-type="user" pool-name="FunkPool"/>
    </resources>

    I placed the necessary SQL driver in the GlassFish Server's directories, i.e. the file mysql-connector-java-5.1.18-bin.jar at ..\GlassFish3\GlassFish\domains\domain1\lib\ext.

    Yet, when I perform a ping test from the JDBC Pool 'FunkPool' at the GlassFish server, I get the following error:

    Ping Connection Pool failed for FunkPool. WEB9031: WebappClassLoader unable to load resource [com.mysql.jdbc.SQLError], because it has not yet been started, or was already stopped Please check the server.log for more details.

    In the server.log I only find the following extra logging exception and failure info:

    (i) Exception while creating an unpooled [test] connection for pool [ FunkPool ], WEB9031: WebappClassLoader unable to load resource [com.mysql.jdbc.SQLError], because it has not yet been started, or was already stopped

    (ii) RestResponse.getResponse() gives FAILURE. endpoint = 'http://localhost:4848/management/domain/resources/ping-connection-pool.json'; attrs = '{id=FunkPool}'

    Note however, that when I ping the database funkOneDB from my IDE NetBeans via jdbc:mysql://localhost:33066/funkOneDB , it's succesful. As already mentioned, the credentials and other data I use for this IDE-based ping are the same data I use in the JDBC Connection Pool.

    I don't know what to do. I googled the problem for quite some time. And I did find some people talking about it, like

    http://tamanmohamed.blogspot.be/2012/03/GlassFish-312-unable-to-load-resource.html

    But when I tried their suggestions nothing changed.

    Can somebody help me solve this problem? Many thanks in advance!

    With kind regards,

    Heinz
    K. Tsang
    Bartender

    Joined: Sep 13, 2007
    Posts: 2503
        
        8

    Try put the mysql jdbc jar file one level up eg ..\GlassFish3\GlassFish\domains\domain1\lib\

    And for the pool settings use "java.sql.Driver" as the resource type and "com.mysql.jdbc.Driver" and driver classname


    K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
    Heinz Uller
    Greenhorn

    Joined: Jun 06, 2013
    Posts: 8
    K. Tsang wrote:Try put the mysql jdbc jar file one level up eg ..\GlassFish3\GlassFish\domains\domain1\lib\

    And for the pool settings use "java.sql.Driver" as the resource type and "com.mysql.jdbc.Driver" and driver classname


    Thanks for your quick reply! I implemented your suggested changes.

    Now I get another error:

    Ping Connection Pool failed for FunkPool. Class name is wrong or classpath is not set for : com.mysql.jdbc.Driver

    Have you got any ideas on how to proceed?

    Kind regards,

    Heinz
    K. Tsang
    Bartender

    Joined: Sep 13, 2007
    Posts: 2503
        
        8

    Did you put in the parameters like URL, user, password etc in Glassfish?

    I set mine JDBC resource like I described it and work for me.
    Heinz Uller
    Greenhorn

    Joined: Jun 06, 2013
    Posts: 8
    K. Tsang wrote:Did you put in the parameters like URL, user, password etc in Glassfish?

    I set mine JDBC resource like I described it and work for me.


    Yes, I did put all the parameters like URL, user, password, port, etc. in place in the GlassFish at the JDBC Pool 'FunkPool' under 'additional properties', and filled them in correctly (I verified this via a ping on the database funkOneDB from my IDE NetBeans via jdbc:mysql://localhost:33066/funkOneDB using the same credentials for user and password).

    In order to deblock my problem, I tried something else (a bit more out of the box).

    I replaced the file mysql-connector-java-5.1.18-bin.jar at ..\GlassFish3\GlassFish\domains\domain1\lib by the file mysql-connector-java-5.1.14-bin.jar (as this is the one talked about in the original GlassFish Oracle documentation). Then I restarted the server, just to be sure. After another ping from the JDBC Pool 'FunkPool', I got the following error again:

    Ping Connection Pool failed for FunkPool. WEB9031: WebappClassLoader unable to load resource [com.mysql.jdbc.SQLError], because it has not yet been started, or was already stopped.

    I am walking in the dark here. Any other suggestions?

    Kind regards for your assistance,

    Heinz




    Hak Vir
    Greenhorn

    Joined: Jul 08, 2013
    Posts: 1
    Hi giuys,

    I have same problem.

    Ping Connection Pool failed for FunkPool. WEB9031: WebappClassLoader unable to load resource [com.mysql.jdbc.SQLError], because it has not yet been started, or was already stopped Please check the server.log for more details.


    But everything is set like should.

    Drives me crazy. Anyone help, please?
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: GlassFish Server does not connect to SQL database (problem with SQL driver)