title: How to make java read a .sql file and execute it in phpmyadmin
body: <p>I'm trying to make the program read the "Entity.sql" File and then execute it to make it run in phpmyadmin. I did used a mysql connector to link netbeans to mysql and then it should used the Connection for phpmyadmin to execute the Statement (Entity.sql)</p>
  
  <p>The Entity.sql file contains as sql Statement: </p>
  
  <pre><code>CREATE DATABASE IF NOT EXISTS Student 
  </code></pre>
  
  <p>The problem is that it's not working and it's giving me this error:</p>
  
  <pre><code>com.mysql.jdbc.exceptions.jdbc4.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
  </code></pre>
  
  <p>here is my entire code: </p>
  
  <pre><code>import java.sql.Connection;
  import java.sql.ResultSet;
  import java.sql.Statement;
  import java.sql.*;
  import java.io.*;
  import java.util.*;
  
  
  public class SQLConnecter {
      private Connection con;
      private Statement st;
      private ResultSet rs;
  
          public SQLConnecter(){
  
          try{
              Class.forName("com.mysql.jdbc.Driver");
              con = DriverManager.getConnection("jdbc:mysql://localhost:3306/","root","");
              st = con.createStatement();                                  
          }
  
          catch(Exception ex){
              System.out.println("Error:"+ ex);
         }
      }
  
  
  public void getData(){
  
      try{
           Scanner infile = new Scanner(new File("Entity.sql"));
      String sql = infile.next();
      while(infile.hasNext()){
      st.executeUpdate(sql);
         }
  
      infile.close();
  }
      catch(Exception ex){
          System.out.println(ex);
      }  
   }
  public static void main(String args[]){
  SQLConnecter connect = new SQLConnecter();
  connect.getData();
  }
  }
  </code></pre>
  
  <p>I want the program to first </p>
  
  <p>1- Read the Entity.sql file</p>
  
  <p>2- Execute the file into phpmyadmin</p>
  
  <p>Can someone please help me to solve this?</p>