@Override
    public void insert(Matrix matrix, int matrix_id) throws SQLException {

        deleteMatrix(matrix_id);

        int rows = matrix.getRowsCount();
        int cols = matrix.getColsCount();

        long startTime = System.currentTimeMillis();

        statement = connection.prepareStatement(insertMatrixString);

        for (int i = 1; i <= rows; i++) {
            for (int j = 1; j <= cols; j++) {
                try {

                    statement.setInt(1, matrix_id);
                    statement.setInt(2, i);
                    statement.setInt(3, j);
                    statement.setDouble(4, matrix.getValue(i - 1, j - 1));
                    statement.addBatch();
//statement.executeUpdate();

                } catch (Exception ex) {
                    System.out.println("Error: " + ex);
                }

            }

        }

        statement.executeBatch();

        statement.close();
        //run time
        long endTime = System.currentTimeMillis();
        long time = endTime - startTime;

        System.out.println("Recording of the data base lasted " + time + " ms.");
    }