0

I uploaded a java app to an OpenShift application. It has the following cartridges:

  • Tomcat 7 (JBoss EWS 2.0)
  • MySQL 5.5
  • phpMyAdmin 4.0

Rhc, git and ssh are all working correctly. But when I run my app, it can't reach the tables in my database. When I had everything in my computer, everything was working fine, this problem appeared when I tried to deploy to OpenShift.

I get following exception:

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

This is how I connect to the db in my app:

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);
    }
}

Then in a controller I execute a simple query using connection previously created.

And when I connect to mysql with ssh I can see that my database and my tables exist:

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)

1 Answers1

3

You have an error on your table name, note that on Unix table names in SQL are case sensitive, even though on Windows they are probably not (check: Are table names in MySQL case sensitive? for an explanation)

So instead of accessing ordenesDeCompra you should be accessing ordenesdecompra.

Community
  • 1
  • 1
João Gonçalves
  • 3,903
  • 2
  • 22
  • 36
  • Thank you @João Gonçalves , in production I was using windows but in deployment I have a Linux server. Changed table names and everything is working fine now – Axel Salomon Rodriguez Mar 16 '16 at 23:48