title: Java creating tables in MySQL Database
body: <p>First of all thanks to those that helped me previously.</p>
  
  <p>The issue that I'm having at the moment, is with either this line of code </p>
  
  <pre><code>    statement.executeUpdate(myTableName);
  </code></pre>
  
  <p>or with these lines of code</p>
  
  <pre><code>    String myTableName = "CREATE TABLE AgentDetail (" 
          + "idNo INT(64) NOT NULL AUTO_INCREMENT,"  
          + "initials VARCHAR(2)," 
          + "agentDate DATE,"  
          + "agentCount INT(64))";  
  </code></pre>
  
  <p>When it code reaches these points, it generates an error which is caught by the SQLException block. </p>
  
  <p>It is either very simple or it is very complicated</p>
  
  <p>Could anybody point out where this newbie to Java MySQL programming has made the error and hopefully not errors, thanks in advance</p>
  
  <p>Here is the Rest of the code in full</p>
  
  <pre><code>    public class DbStuff {
      private String jdbcDriver = "com.mysql.jdbc.Driver";
      private String dbAddress = "jdbc:mysql://localhost:3306/";
      private String userPass = "?user=root&amp;password=";
      private String dbName = "TIGER19";
      private String userName = "root";
      private String password = "";
  
      private PreparedStatement preStatement;
      private Statement statement;
      private ResultSet result;
      private Connection con;
  
      public DbStuff() {
          try {
              Class.forName(jdbcDriver);
              con = DriverManager.getConnection(dbAddress + dbName, userName, password);
          } 
          catch (ClassNotFoundException e) {
              e.printStackTrace();
          } 
          catch (SQLException e) {
              createDatabase();
              createTableCub1();
          }
      }
  
      private void createDatabase() {
          try {
              Class.forName(jdbcDriver);
              con = DriverManager.getConnection(dbAddress + userPass);
              Statement s = con.createStatement();
              int myResult = s.executeUpdate("CREATE DATABASE IF NOT EXISTS " + dbName);
          } 
          catch (ClassNotFoundException | SQLException e) {
              e.printStackTrace();
          }
      }
  
      private void createTableCub1() {
          String myTableName = "CREATE TABLE AgentDetail (" 
              + "idNo INT(64) NOT NULL AUTO_INCREMENT,"  
              + "initials VARCHAR(2)," 
              + "agentDate DATE,"  
              + "agentCount INT(64))";  
          try {
              Class.forName(jdbcDriver);
              con = DriverManager.getConnection(dbAddress + dbName, userName, password);
              statement = con.createStatement();
              //The next line has the issue
              statement.executeUpdate(myTableName);
              System.out.println("Table Created");
          }
          catch (SQLException e ) {
              System.out.println("An error has occurred on Table Creation");
          }
          catch (ClassNotFoundException e) {
              System.out.println("An Mysql drivers were not found");
          }
      }
      }
  </code></pre>