Table 在连接到 OpenShift 的 mysql 时不存在

Table doesn't exist when connecting to OpenShift's mysql

我将 java 应用程序上传到 OpenShift 应用程序。 它有以下墨盒:

Rhc、git 和 ssh 都正常工作。但是当我 运行 我的应用程序时,它无法访问我数据库中的表。当我把所有东西都放在我的电脑上时,一切正常,当我尝试部署到 OpenShift 时出现了这个问题。

我得到以下异常:

com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 'mytomcatapp.ordenesDeCompra' doesn't exist

这是我在我的应用程序中连接到数据库的方式:

private static final String host = System.getenv("OPENSHIFT_MYSQL_DB_HOST");
private static final String port = System.getenv("OPENSHIFT_MYSQL_DB_PORT");
private static final String stringConexion = String.format("jdbc:mysql://%s:%s/mytomcatapp", host, port);

private static Connection conexion;

public static void conectar() {

    try {
        Class.forName("com.mysql.jdbc.Driver");
        conexion = DriverManager.getConnection(stringConexion, "myUser", "myPassword");

    } catch (ClassNotFoundException | SQLException ex) {
        Logger.getLogger(ConexionBD.class.getName()).log(Level.SEVERE, null, ex);
    }
}

然后在控制器中,我使用之前创建的连接执行一个简单的查询。

当我使用 ssh 连接到 mysql 时,我可以看到我的数据库和表存在:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| mytomcatapp        |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)

mysql> use mytomcatapp; go; show tables;
Database changed
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'go' at line 1
+-----------------------+
| Tables_in_mytomcatapp |
+-----------------------+
| jurisdicciones        |
| ordenesdecompra       |
| proveedores           |
| subtitulos            |
| tiposcontratacion     |
+-----------------------+
5 rows in set (0.00 sec)

您的 table 名称有误,请注意在 Unix table 中 SQL 中的名称区分大小写,即使在 Windows 中它们可能不区分大小写(检查:Are table names in MySQL case sensitive? 以获得解释)

所以您应该访问 ordenesdecompra.

而不是访问 ordenesDeCompra