gpt4 book ai didi

Java/GlassFish MySQLNonTransientConnectionException

转载 作者:行者123 更新时间:2023-11-29 16:14:18 26 4
gpt4 key购买 nike

尝试使用在 NetBeans 上运行的 GlassFish 服务器连接到 MySQL 时总会出现此异常。

(com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException) com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: 无法打开文件:C:\Users\houssam.ayyache\AppData\Roaming\NetBeans\8.2\config\GF_4.1.1\domain1/config/keystore.jks [Keystore被篡改,或密码错误]

如果部署在 Apache Tomcat 上或使用旧版本的 MySQL(在 5.7 上测试),它似乎可以工作。

我正在使用此代码来创建连接。

private Connection getConnection(String ip, int port, String dataBaseName, String userName, String password) {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException ex) {
Logger.getLogger(DynamicContactMySQLAdapter.class
.getName()).log(Level.SEVERE, null, ex);
}
try {
DriverManager.setLoginTimeout(10);
conn = DriverManager.getConnection("jdbc:mysql://" + ip + ":" + port + "/" + dataBaseName, userName, password);
} catch (SQLException ex) {
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
conn = null;
}
return conn;
}

任何有关原因或如何解决此问题的想法都值得赞赏:)

异常堆栈跟踪:

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Cannot open file:C:\Users\houssam.ayyache\AppData\Roaming\NetBeans\8.2\config\GF_4.1.1\domain1/config/keystore.jks [Keystore was tampered with, or password was incorrect]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc.Util.getInstance(Util.java:408)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:898)
at com.mysql.jdbc.ExportControlled.getSSLSocketFactoryDefaultOrConfigured(ExportControlled.java:401)
at com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket(ExportControlled.java:103)
at com.mysql.jdbc.MysqlIO.negotiateSSLConnection(MysqlIO.java:4914)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1663)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1224)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2199)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2230)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2025)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:778)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:386)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at com.monty.smspluginshared.dynamiccontactdatasource.adapter.DynamicContactMySQLAdapter.getConnection(DynamicContactMySQLAdapter.java:80)
at com.monty.smspluginshared.dynamiccontactdatasource.adapter.DynamicContactMySQLAdapter.getCommandFields(DynamicContactMySQLAdapter.java:142)
at com.monty.smsplugin.api.DynamicContactCommandFields.processRequest(DynamicContactCommandFields.java:58)
at com.monty.smsplugin.api.DynamicContactCommandFields.doPost(DynamicContactCommandFields.java:109)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at com.monty.smspluginapi.AuthenticationFilter.doFilter(AuthenticationFilter.java:50)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:748)

Caused by: java.io.IOException: Keystore was tampered with, or password was incorrect
at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:780)
at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:56)
at sun.security.provider.KeyStoreDelegator.engineLoad(KeyStoreDelegator.java:224)
at sun.security.provider.JavaKeyStore$DualFormatJKS.engineLoad(JavaKeyStore.java:70)
at java.security.KeyStore.load(KeyStore.java:1445)
at com.mysql.jdbc.ExportControlled.getSSLSocketFactoryDefaultOrConfigured(ExportControlled.java:381)
... 57 more

Caused by: java.security.UnrecoverableKeyException: Password verification failed
at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:778)
... 62 more

最佳答案

今天我也遇到了和你一样的问题。我通过将 &useSSL=false 添加到我的网址来修复它,如下所示:

static final String DB_URL = "jdbc:mysql://localhost:3306/mytzzy?serverTimezone=UTC&useSSL=false";

个人来说,断线不是mysql-connector.jar或者netbeans本身造成的,如果在netbeans这里可以连接mysql enter image description here祝你好运:)

关于Java/GlassFish MySQLNonTransientConnectionException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54968814/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com