Two things can be fixed here:
public static void get_data()
This method is declared as returnable. Change it to:
public static String[] get_data()
Your String[] data_array declared in a while loop, so it is only known there. Your return statement is outside of this loop, so it does not have access to it.
Move the variable outside the loop:
String sql = "SELECT data_x FROM table_x"; ResultSet result = query.executeQuery(sql); String[] data_array = new String[999];
Remember that you need to move the declaration and initialization outside the while , otherwise you will overwrite the previously saved data of this array, initializing it again. And also remember that your for loop will overwrite the current data anyway ... you should consider storing the string data in another array so that it is lost.
source share