我收到以下异常:
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连接时未选择数据库异常
发布评论