title: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException exception in CentOS server
body: <p>Running a java code in CentOS server to connect mysql</p>
  
  <p>My code is -</p>
  
  <pre><code>String server = "", url = "", password = "", user = "", databasename = "";
      Connection con = null;
      try {
          server = "xxx.xxx.xxx.xxx";
          databasename = "xx";
          user = "user";
          password = "pass";
          Class.forName("com.mysql.jdbc.Driver");
          url = "jdbc:mysql://" + server + "/" + databasename + "";
          con = DriverManager.getConnection(url, user, password);
          System.out.println(server + " Database connection established");
          System.out.println(con);
      } catch (Exception e) {
          System.out.println("***************connection failed********************");
          e.printStackTrace();
      }
  </code></pre>
  
  <p>My database is running in same server.</p>
  
  <p>I am running this code in my local system and other server for same database and its running fine but its not running on same server where my database available.
  I am getting this exception -</p>
  
  <pre><code>    com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: 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 '??????????????' at line 1
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1027)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3361)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3295)
     at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1852)
     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1975)
     at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2470)
     at com.mysql.jdbc.ConnectionImpl.configureClientCharacterSet(ConnectionImpl.java:1669)
     at com.mysql.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:3336)
     at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1979)
     at com.mysql.jdbc.ConnectionImpl.&lt;init&gt;(ConnectionImpl.java:718)
     at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:287)
     at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:283)
     at java.sql.DriverManager.getConnection(libgcj.so.10)
     at java.sql.DriverManager.getConnection(libgcj.so.10)
     at testthread.ConnectionFactory.getConnection(ConnectionFactory.java:28)
     at testthread.ConnectionFactory.main(ConnectionFactory.java:39)
  </code></pre>
  
  <p>is any one help me what is the problem.</p>