title: Can I run a "source" command (SQL script) from a JDBC connection?
body: <p>I'm writing an application that has a data access layer to abstract the underlying connections to SQLITE3 or MySQL databases.</p>
  
  <p>Thanks to some help here yesterday I was shown how to use a process builder to run a command line import into the SQLITE3 DB using output redirection.</p>
  
  <p>Now I am trying to create the same database but in MySQL by importing a dump file. The load works fine from the command line client. I just tell it to source the file and the DB is created successfully.</p>
  
  <p>However I am trying to do this through code at runtime and my method for executing a SQL statement fails to execute the source command. </p>
  
  <p>I suspect that this is because "source" is not SQL but I don't know what else to use to try and run it.</p>
  
  <p>My error message is:</p>
  
  <pre><code>java.sql.SQLSyntaxErrorException: 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 'source /tmp/ISMCoreActionPack_mysql.sql' at line 1
  </code></pre>
  
  <p>The failing command string:</p>
  
  <pre><code>source /tmp/ISMCoreActionPack_mysql.sql;
  </code></pre>
  
  <p>My method is:</p>
  
  <pre><code>public Boolean executeSqlStatement(String sql)  {
      Boolean rc = false;
      try {
        Connection connection = getConnection();
        Statement statement = connection.createStatement();
        rc = statement.execute(sql);
        connection.close();
      } catch (SQLException e) {
        e.printStackTrace();
        System.err.println(e.getClass().getName() + ": " + e.getMessage());
        System.exit(1);
      }
      return rc;
  }
  </code></pre>
  
  <p>Can anyone suggest how to do this?</p>