[英]MySQLSyntaxErrorException: Unknown database - JDBC - Java EE
Really odd issue here, it was working a few days ago.这里真的很奇怪的问题,几天前它正在工作。 I create a new database for a new project and I go to run it and I get the following error我为一个新项目创建了一个新数据库,然后我去运行它,但出现以下错误
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database
So I went back to my older projects and tried to run them.所以我回到我的旧项目并尝试运行它们。 Same error.同样的错误。
The database is definitely there, it's named correctly, i'm using user "root".数据库肯定在那里,它命名正确,我正在使用用户“root”。 MySQL is started, I can interact with it in terminal... any particular reason I may be getting this error? MySQL 已启动,我可以在终端中与它进行交互......我可能会收到此错误的任何特殊原因?
Connection c = DriverManager.getConnection("jdbc:mysql://localhost/twittermap","root","");
In terminal:在终端:
select CURRENT_USER()
will return root@localhost将返回 root@localhost
SELECT DATABASE() FROM DUAL;
returns twittermap返回推特地图
show variables like 'port';
returns 3306返回 3306
If any more information is required please let me know and I will post it immediately.如果需要更多信息,请告诉我,我会立即发布。 This is most likely a simple fix but I just can't wrap my head around it.这很可能是一个简单的修复,但我无法理解它。 Thanks all, really appreciate the help!谢谢大家,非常感谢您的帮助!
EDIT: I ran netstat -tnl and 127.0.0.1:3306 is NOT listed.. ?编辑:我运行了 netstat -tnl 并且没有列出 127.0.0.1:3306 ..?
就这样写:
Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/twittermap","root","");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.