• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Heinz Uller
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Posts: 3401
    13
    Android Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
     
    Heinz Uller
    Greenhorn
    Posts: 8
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 3401
    13
    Android Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 8
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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?
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic