Linux-Ubuntu 问题:连接mysql后找不到mysql数据库
1. I have a war file deployed in webapps folder at /srv/apache-tomcat-7.0.53/webapps/
War name is InIndia.war
2. I have deployed inindiadb.properties in classpath which is /srv/apache-tomcat-7.0.53/lib
Contents of inindiadb.properties
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/inindia
jdbc.username=root
jdbc.password=admin
3. I have mysql installed and running
netstat -vulntp |grep -i mysql
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 563/mysqld
4. MySql Database has inindia database and inindia has 3 tables (place , user_roles , users)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| inindia |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec)
mysql> use inindia;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+-------------------+
| Tables_in_inindia |
+-------------------+
| place |
| user_roles |
| users |
+-------------------+
3 rows in set (0.00 sec)
5. The problem is when I restart my tomcat , a connection is made to the mysql but in tomcat logs it says that
**catalina.out**
SEVERE: Error listenerStart
Apr 18, 2014 11:02:17 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/InIndia] startup failed due to previous errors
**localhostlocalhost.2014-04-18.log**
INFO: Initializing Spring root WebApplicationContext
Apr 18, 2014 10:50:11 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class com.inindia.listener.ApplicationInfoLoaderListener
org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [SELECT * FROM PLACE order by placeName]; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'inindia.PLACE' doesn't exist
- 我无法找出错误。该错误表明无法找到 inindia.Place,但存在数据库和表。
- 它连接到 inindiadb.properties 文件中提到的 URL
我什至写了一个 java 类来连接到 mysql 服务器并显示为其中一个表的输出数据。连接和数据获取都成功。
即使我在我的本地 tomcat 上部署了相同的部署正确的窗口。因此 war 似乎没有问题
我是 linux 的新手。请告诉我是否需要在 mysql 服务器中进行任何设置。比如为数据库提供特权或类似的东西
最佳答案
表名区分大小写。使用适当的大小写
关于java - linux连接mysql后找不到数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23153250/