title: MySQL - checking if column exists if not create it in Java
body: <p>I've spent a few hours researching on how to create a Java method that will help with my program. I am very new to MySQL, so I am not the most experienced person out there.</p>
  
  <p>What I am trying to do is write a Java method that checks if a column that has the is named after a username exists inside of a table. If it does not exists, it will create that column.</p>
  
  <p>I have seen lot's of tutorials on the internet about similar solutions to my problem. I don't see how I am supposed to implement the TABLE_SCHEMA into a java method since I only know the very basics of MySql.</p>
  
  <p>It would be nice to see how to implement this or some other solution into the Java method. I've mostly erased my previous work since I could not figure it out, so sorry if I need to show that(This is my first question.)</p>
  
  <p>Edit:</p>
  
  <pre><code>        try {
          ResultSet res = conn.createStatement()
                  .executeQuery("ALTER TABLE `package_table` ADD " + username + "  VARCHAR(15);");
          if (!res.next()) {
              conn.createStatement()
                      .executeUpdate("INSERT INTO `package_table` (`uuid`, `name`, `packages`) VALUE ('"
                              + event.getPlayer().getUniqueId() + "', '" + event.getPlayer().getName() + "', '" + "" + "');");
          }
      } catch (SQLException e) {
          e.printStackTrace();
          try {
              conn.close();
          } catch (SQLException e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
          }
      }
  </code></pre>
  
  <p>Edit2:
   The reason I need to do columns is that I need to store the 'packages' a username has. There can be "infinite" amounts of packages.</p>
  
  <p>Thanks,
  Jack</p>