Skip to Main Content

MySQL Database

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

CHANGE THE OUTPUT TO INSERT DATA TO MYSQL'S TABLE

Joao Valencio SilvaAug 10 2018 — edited Aug 12 2018

Hello,

Please, I need help to change the output of the following code,

I need the output to be to fill the column named `combinations`, that belongs to the table named `table1` of the MySQL's database named `numbers`.

At the moment, the results are displayed to the console, and I need to change it to fill a specified column of a table in MySQL.

Regards,

John

class Permutation {

    static void combinationUtil(int arr[], int data[], int start,

                                int end, int index, int r)

    {

        if (index == r)

        {

            for (int j=0; j<r; j++)

            System.out.print(data[j]+" ");

            System.out.println("");

            return;

        }

        for (int i=start; i<=end && end-i+1 >= r-index; i++)

        {

            data[index] = arr[i];

            combinationUtil(arr, data, i+1, end, index+1, r);

        }

    }

    static void printCombination(int arr[], int n, int r)

    {

        int data[]=new int[r];

        combinationUtil(arr, data, 0, n-1, 0, r);

    }

    public static void main (String[] args) {

        int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};

        int r = 6;

        int n = arr.length;

        printCombination(arr, n, r);

    }

}

Comments

Post Details

Added on Aug 10 2018
1 comment
86 views