title: How to store multidimensional array values to MySQL database in java?
body: <p>I would like to ask how to store multidimensional array to MySQL database. 
  For example i have an array of (x, y) </p>
  
  <pre><code>array[][] = {
  {3, 10},
  {2, 11},
  {4, 9},
  }
  </code></pre>
  
  <p>i tried using preparedStatement setInt to store those values to mysql database but the output turned out like this:  </p>
  
  <pre><code>java.lang.ArrayIndexOutOfBoundsException: 3
  </code></pre>
  
  <p>this is the code : </p>
  
  <pre><code>import java.sql.*; 
  import java.util.logging.Level;
  import java.util.logging.Logger;
  
  public class InsertDB {
  
      public static void main(String[] args) {
          Connection conn = null; 
          Statement exe = null; 
  
  
  
      int[][] multiarray = { 
                 {3, 10},
                 {2, 11},
                 {4, 9},
              };
  
          try {
              Class.forName("com.mysql.jdbc.Driver");
              System.out.println("Connecting to the database");
              conn = DriverManager.getConnection("jdbc:mysql://localhost/finalproject","root","");
              System.out.println("Database connected");
              exe = conn.createStatement();
  
              conn.setAutoCommit(false);
              PreparedStatement stmt = null;
              stmt = conn.prepareStatement("INSERT INTO SIGNATURE (angle, distance) VALUES (?,?)");
              for (int i = 0; i &lt; 10; i++) {
                 stmt.setInt(1, multiarray[i][0]);
                 stmt.setInt(2, multiarray[i][1]);
                 stmt.addBatch();
              }
  
              stmt.executeBatch();
              conn.commit();
  
              System.out.println("Data added !  ");
          } catch (ClassNotFoundException ex) {
              Logger.getLogger(InsertDB.class.getName()).log(Level.SEVERE, null, ex);
          } catch (SQLException ex) {
              Logger.getLogger(InsertDB.class.getName()).log(Level.SEVERE, null, ex);
          }finally{
              try{
                  if (exe != null)
                      conn.close();
              }catch (SQLException se){
  
              }try{
                  if(conn != null)
                      conn.close();
              }catch(SQLException se){
  
              }
      }
          System.out.println("Done !");
      }
  
  }
  </code></pre>
  
  <p>can someone solve this problem, </p>
  
  <p>thanks :)</p>