title: Calling mysql.exe from Java
body: <p>I am calling mysql.exe from Java to load a database. Because the process just hangs, I need to create a command file and pass in the username and password. </p>
  
  <p>Example contents of command.bat:</p>
  
  <pre><code>mysql --user="%1" --password="%2" mydatabase &lt; myscript.sql
  </code></pre>
  
  <p>The problem is that I cannot see the output of the mysql command to see if there were any errors. They display on the command line, but I cannot seem to capture them in a file for parsing or an InputStream.</p>
  
  <p>How can I see the output of the mysql command?</p>
  
  <p>NOTE: Calling mysql.exe directly from Java hangs because the mysql does not appear to be sending the information to the buffer.</p>
  
  <p>NOTE: We are using mysql.exe instead of JDBC because we need to update things like triggers. In order to submit all the statements to the db, we would need to parse all the commands and pass them in one at a time.</p>
  
  <p>NOTE: This is a running MySQL database that needs to be upgraded.</p>