连接到Glassfish中的mysql

时间:2018-06-10 14:54:40

标签: php mysql glassfish quercus

我的目标是在glassfish服务器上运行php。我安装了Quercus并将其部署为glassfish中的应用程序(C:\ glassfish4 \ glassfish \ domains \ domain1 \ applications \ Quercus)。

现在我尝试连接到mysql。 mysql服务器正在运行,并通过命令验证连接(mysql -u root -p)。

创建下一个test.php:

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

运行test.php会显示以下消息:

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!

从消息中,很可能没有安装mysql jdbc驱动程序。

我将驱动程序添加到C:\ glassfish4 \ glassfish \ domains \ domain1 \ lib \ mysql-connector-java-8.0.11 \ mysql-connectior-java-8.0.11.jar。我不知道如何从glassfish管理控制台添加它。它未显示在jdbc&gt;连接池下。

第二次编辑(根据评论): jar文件也被移动到... \ domain1 \ lib和... \ glassfish \ lib中。完成系统重启。 要添加连接池,我按照以下链接中的说明操作: https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-usagenotes-glassfish-config.html

然后我收到以下错误消息:

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.
...

0 个答案:

没有答案