java.sql.SQLException:通过tomcat连接时未选择数据库异常

编程入门 行业动态 更新时间:2024-10-11 07:35:31
本文介绍了java.sql.SQLException:通过tomcat连接时未选择数据库异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我收到以下异常:

Caused by: java.sql.SQLException: No database selected at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:996) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3887) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3823) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2435) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2582) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2530) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1907) at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2030) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:82) ... 52 more

我将CentOS 7与MariaDB(tomcat8/java8)一起使用.我已经更改了maria db的myf中的默认端口,然后->发生了此异常.我使用了休眠模式,并且已经更改了hibernate.cfg.xml的端口

I use CentOS 7 with MariaDB (tomcat8 / java8). I've changed the default Port in the myf of maria db, then -> this exception occured. I use hibernate and i have already changed the port in the hibernate.cfg.xml

是否可以通过其他端口连接到mysql?而不是3306,还是不建议这样做?

Is it possible to connect to mysql via a different port? instead of 3306 or is this not recommended?

我已恢复为端口3306(默认),然后出现以下异常:

I've reverted to port 3306 (default) then i get following exception:

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet successfully received from the server was 17,287 milliseconds ago. The last packet sent successfully to the server was 1 milliseconds ago. 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:408)

谢谢

推荐答案

已解决

tomcat重新启动脚本(服务)是问题所在.可能服务器重启不干净并且连接池大小已超过.

the tomcat restart script (service) was the problem. may the restart of the server was not clean and the connection pool size exeeded.

手动执行shutdown.sh和startup.sh-问题已解决".

Manually executed the shutdown.sh and the startup.sh - problem "solved".

谢谢!

更多推荐

java.sql.SQLException:通过tomcat连接时未选择数据库异常

本文发布于:2023-11-10 14:24:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1575615.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:异常   数据库   sql   java   tomcat

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!