0

My goal is to run php on glassfish server. I installed Quercus and deployed it as an application within glassfish under (C:\glassfish4\glassfish\domains\domain1\applications\Quercus).

Now I try to connect to mysql. The mysql server is running and connection is verified through command (mysql -u root -p).

next test.php is created:

<?php
    $servername="localhost";
    $username="root";
    $password="whatever";
    $conn = new mysqli($servername, $username, $password);
    if (!$conn) {
        die("Failed : " . mysqli.connect_error());
    }
    echo "Connection Successful!";
?>

Running test.php gives the following message:

Warning: A link to the server could not be established.
url=jdbc:mysql://localhost/?
jdbcCompliantTruncation=false&characterSetResults=ISO885_1&characterEncoding=ISO8859_1&userServerPrepStmts=true
driver=com.mysql.jdbc.Driver com.caucho.quercus.QuercusModuleException:java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Connection Successful!

From the message, it is probable that the mysql jdbc driver is not installed.

I added the driver to C:\glassfish4\glassfish\domains\domain1\lib\mysql-connector-java-8.0.11\mysql-connectior-java-8.0.11.jar. I am not sure how to add it from glassfish admin console. It is not shown under jdbc>connection pool.

2nd EDIT (based on comments): The jar files are moved into ...\domain1\lib and ...\glassfish\lib as well. A full system restart was done. To add a connection pool, I Followed the instructions on the following link: https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-usagenotes-glassfish-config.html

Then I get the following error message:

HTTP Status 500 - Internal Server Error:
type Exception report
message Internal Server Error
description The server encountered an internal error that prevented it from fulfilling this request.
exception java.lang.IllegalStateException: getoutputStream() has already been called for this response.
...
mtleis
  • 712
  • 1
  • 9
  • 28
  • Possible duplicate of [Where to add the jdbc driver on Netbeans/Glassfish in Windows?](https://stackoverflow.com/questions/27078016/where-to-add-the-jdbc-driver-on-netbeans-glassfish-in-windows) – fvu Jun 10 '18 at 15:00
  • question edited after trying to add the jar file. I still failed to configure it in admin console. – mtleis Jun 10 '18 at 17:22
  • Connection pools don't just appear/autoconfigure, you have to configure them per connection. It's well explained in the Glassfish docs. – fvu Jun 10 '18 at 17:43
  • I would put the jdbc driver in either `C:\glassfish4\glassfish\domains\domain1\lib` (as a domain lib) or `C:\glassfish4\glassfish\lib` (as a global lib). I have no experience with Quercus' mysqli driver, but I just had a quick look at the implementation, I don't think you need to configure jdbc resources in GF to make it work. So, if the driver is at the correct place it should work. – fvu Jun 10 '18 at 18:56
  • It did work! Placing the driver in its location was sufficient! (would you like to move your comment as an answer). – mtleis Jun 11 '18 at 07:50
  • Well I already flagged your question as a duplicate, because my comment is just a slightly more explicit version of what the answer to the other question says (adapted to your actual installdir). Therefore I don't think it would be appropriate to willingly create a dupe q&a :) My goal was to get you going, and I succeeded, that should be sufficient :) – fvu Jun 11 '18 at 09:34

0 Answers0