次のようなテキストファイルがあります。
    george   19   180     75
    paul     20   182     84
    laura    21   176     73
    ...      ...  ...     ...
このファイルを読み取り、その内容をデータベース内のパラメータ (名前、年齢、身長、体重) を持つテーブルに追加したいと考えています。ジョージ、ポール、ローラという名前を名前などに追加する必要があります。私はこのようなコードを書きました。
    public static void main(String[] args) throws IOException {
    PreparedStatement preparedstatement = null;
    try{
        String read=null;
        in = new BufferedReader(new FileReader("patientlist.txt")); 
        while ((read = in.readLine()) != null) {
            String[] splited = read.split("\\s+");
            name=splited[0];
            age=splited[1];
            height=splited[2];
            weight=splited[3];       
        }
        try {
            addpatient(connection, preparedstatement, name, age, height, weight);   
            if (connection != null)
            try{connection.close();} catch(SQLException ignore){}
            }
        catch (SQLException error) {System.out.println(error);} 
    }
    catch (IOException e) {System.out.println("There was a problem: " + e);}        
    }
    public static void addpatient(Connection connection, PreparedStatement preparedstatement, String name, String age2, String height2, String weight2) throws SQLException{
    preparedstatement=connection.prepareStatement("insert into allpatients(name, age, height, weight) values(?,?,?,?)");
    preparedstatement.setString(1, name);
    preparedstatement.setString(2, age);
    preparedstatement.setString(3, height);
    preparedstatement.setString(4, weight);
    preparedstatement.executeUpdate();
}
問題は while ループにあると思います。おそらく for ループを追加する必要がありますが、それを行うことができませんでした。私はあまり優れたプログラマーではありません。助けに感謝します。ありがとう!