• <legend id='Gkx2k'><style id='Gkx2k'><dir id='Gkx2k'><q id='Gkx2k'></q></dir></style></legend><tfoot id='Gkx2k'></tfoot>

        <small id='Gkx2k'></small><noframes id='Gkx2k'>

      1. <i id='Gkx2k'><tr id='Gkx2k'><dt id='Gkx2k'><q id='Gkx2k'><span id='Gkx2k'><b id='Gkx2k'><form id='Gkx2k'><ins id='Gkx2k'></ins><ul id='Gkx2k'></ul><sub id='Gkx2k'></sub></form><legend id='Gkx2k'></legend><bdo id='Gkx2k'><pre id='Gkx2k'><center id='Gkx2k'></center></pre></bdo></b><th id='Gkx2k'></th></span></q></dt></tr></i><div id='Gkx2k'><tfoot id='Gkx2k'></tfoot><dl id='Gkx2k'><fieldset id='Gkx2k'></fieldset></dl></div>
          <bdo id='Gkx2k'></bdo><ul id='Gkx2k'></ul>

        如何使用 JDBC 连接 XAMPP MySQL 本地数据库?

        时间:2023-09-26
        <legend id='UsIZu'><style id='UsIZu'><dir id='UsIZu'><q id='UsIZu'></q></dir></style></legend>

              <bdo id='UsIZu'></bdo><ul id='UsIZu'></ul>

                <tbody id='UsIZu'></tbody>
                  <i id='UsIZu'><tr id='UsIZu'><dt id='UsIZu'><q id='UsIZu'><span id='UsIZu'><b id='UsIZu'><form id='UsIZu'><ins id='UsIZu'></ins><ul id='UsIZu'></ul><sub id='UsIZu'></sub></form><legend id='UsIZu'></legend><bdo id='UsIZu'><pre id='UsIZu'><center id='UsIZu'></center></pre></bdo></b><th id='UsIZu'></th></span></q></dt></tr></i><div id='UsIZu'><tfoot id='UsIZu'></tfoot><dl id='UsIZu'><fieldset id='UsIZu'></fieldset></dl></div>

                  <small id='UsIZu'></small><noframes id='UsIZu'>

                  <tfoot id='UsIZu'></tfoot>
                1. 本文介绍了如何使用 JDBC 连接 XAMPP MySQL 本地数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有这个用 Java 编写的俄罗斯方块游戏,它使用 DB 来记录高分.只要我使用远程 MySQL 数据库,它就可以正常工作,但现在我正在尝试使用 XAMPP MySQL 设置 localhost 数据库,并且它在命令中一直像SQLException:通信链接失败"一样:

                  I have this Tetris game written in Java, which uses DB to record high scores. It worked ok as long as I was using remote MySQL DB, but now I'm trying to set up localhost DB using XAMPP MySQL and it keeps going like "SQLException: Communications link failure" at command:

                  con = java.sql.DriverManager.getConnection("jdbc:mysql://localhost/score", user, psw);
                  

                  我猜是错误的 URL 或数据库配置,但我真的不知道要检查什么.有什么想法吗?

                  I guess it's either wrong URL or DB configuration, but I really don't know what to check. Any ideas?

                  我的朋友解决了我的问题,将 URL 中的localhost"替换为127.0.0.1"(这很尴尬,你可以想象 :P).

                  My friend has fixed my problem by replacing "localhost" in URL by "127.0.0.1" (which was quite embarrassing as you can surely imagine :P ).

                  所以问题是:为什么 XAMPP 无法将localhost"转换为 IP 地址以及如何解决?

                  推荐答案

                  为什么 XAMPP 无法将localhost"翻译成 IP 地址以及如何解决?

                  这不是 XAMPP 问题,也不是编程问题.这更像是一个 DNS 问题.

                  This is not a XAMPP problem nor a programming problem. This is more a DNS problem.

                  首先,您是否有一个 %SystemRoot%/system32/drivers/etc/hosts 文件,其中以下行作为 first 行?(因此,在所有评论之后,但在任何其他主机声明之前)

                  To start, do you have a %SystemRoot%/system32/drivers/etc/hosts file with the following line as first line? (thus, after all comments, but before any other host declarations)

                  127.0.0.1 localhost
                  

                  更新: 根据我的评论 谷歌了一下,看起来 MySQL JDBC 驱动程序不吃 IPv6地址.换句话说,您需要将 ::1 更改为 127.0.0.1.但是我也发现 this topic 里面提到可以使用下面的JVM解决这个问题的论据:

                  Update: as per the comments I've Googled a bit and it look like that the MySQL JDBC driver doesn't eat IPv6 addresses at all. In other words, you'll need to change ::1 to 127.0.0.1. But I also found this topic which mentions that you can use the following JVM argument to fix this problem:

                  java -Djava.net.preferIPv4Stack=true 
                  

                  这篇关于如何使用 JDBC 连接 XAMPP MySQL 本地数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:FTPClient Uploading File = SocketException: Connection reset 下一篇:解析 YAML 文件

                  相关文章

                  最新文章

                    1. <small id='Q7jVB'></small><noframes id='Q7jVB'>

                      <tfoot id='Q7jVB'></tfoot>

                      <i id='Q7jVB'><tr id='Q7jVB'><dt id='Q7jVB'><q id='Q7jVB'><span id='Q7jVB'><b id='Q7jVB'><form id='Q7jVB'><ins id='Q7jVB'></ins><ul id='Q7jVB'></ul><sub id='Q7jVB'></sub></form><legend id='Q7jVB'></legend><bdo id='Q7jVB'><pre id='Q7jVB'><center id='Q7jVB'></center></pre></bdo></b><th id='Q7jVB'></th></span></q></dt></tr></i><div id='Q7jVB'><tfoot id='Q7jVB'></tfoot><dl id='Q7jVB'><fieldset id='Q7jVB'></fieldset></dl></div>
                    2. <legend id='Q7jVB'><style id='Q7jVB'><dir id='Q7jVB'><q id='Q7jVB'></q></dir></style></legend>
                        <bdo id='Q7jVB'></bdo><ul id='Q7jVB'></ul>