title: Inserting into multiple tables using a single query in preparestatement
body: <p>This is my code</p>
  
  <pre><code>String query = "insert into Branch (CompanyID,BranchName,BranchAddress,Email,Phone,ContactPerson) values (?,?,?,?,?,?);insert into Activities(EmployeeID,ActivityType,Activities) values (?,?,?)";
  
              // System.out.println(mobile);//BranchName      | BranchAddress      | Email      | Phone      | ContactPerson
  
              pstmt = conn.prepareStatement(query);
              pstmt.setString(1, compid);
              pstmt.setString(2, name);
              pstmt.setString(3, address);
              pstmt.setString(4, email);
              pstmt.setString(5, mobile);
              pstmt.setString(6, contactperson);
              pstmt.setString(7, empid);
              pstmt.setString(8, acttype);
              pstmt.setString(9, activity);
              System.out.println(query+"-----"+acttype);
              pstmt.execute();
              status = true;
  </code></pre>
  
  <p>If I insert without dynamic values it gets inserted otherwise I get the below 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 'insert into Activities(EmployeeID,ActivityType,Activities) values ('6','createbr' at line 1
  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 'insert into Activities(EmployeeID,ActivityType,Activities) values ('6','createbr' at line 1
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
      at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
      at com.mysql.jdbc.Util.getInstance(Util.java:386)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1053)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4120)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4052)
      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2503)
      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2664)
      at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2794)
      at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155).........
  </code></pre>
  
  <p>How can I overcome this ??? I am able to insert using this statement below</p>
  
  <pre><code>insert into Branch (CompanyID,BranchName,BranchAddress,Email,Phone,ContactPerson) values ('1','sample','11 cross','fakemail@gmail.com','5467897656','Deigo');insert into Activities(EmployeeID,ActivityType,Activities) values ('6','createdbranch','cearted branch sample');
  </code></pre>
  
  <p>But I want it to be dynamic.Please help</p>