import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import java.sql.*;
import java.time.LocalDate;
//import com.mysql.jdbc.PreparedStatement;
public class Speiseplan extends Application {
@Override
public void start(Stage stage) throws Exception {
final TextArea ta1 = new TextArea();
ta1.setPrefRowCount(5);
ta1.setPrefColumnCount(10);
ta1.setPrefWidth(250);
ta1.setPrefHeight(100);
ta1.setLayoutX(100);
ta1.setLayoutY(50);
final TextArea ta2 = new TextArea();
ta2.setPrefRowCount(5);
ta2.setPrefColumnCount(10);
ta2.setPrefWidth(250);
ta2.setPrefHeight(100);
ta2.setLayoutX(400);
ta2.setLayoutY(50);
final TextArea ta3 = new TextArea();
ta3.setPrefRowCount(5);
ta3.setPrefColumnCount(10);
ta3.setPrefWidth(250);
ta3.setPrefHeight(100);
ta3.setLayoutX(700);
ta3.setLayoutY(50);
LocalDate today = LocalDate.now();
int i = 1;
while(i<5){
try {
String url ="jdbc:mysql://localhost:3306/speiseplan";
String username ="root";
String password = "";
//1. get connection
Connection myConn = DriverManager.getConnection(url, username,password);
//2. create a statement
Statement myStmnt = myConn.createStatement();
//3. execute SQL query
ResultSet myRs = myStmnt.executeQuery("select * from gerichte where date= '" + today.toString() + "'");
while (myRs.next()){
String date = myRs.getString("date");
String name = myRs.getString("name");
String type = myRs.getString("type");
ta1.appendText(date + "\n");
ta2.appendText(name + "\n");
ta3.appendText(type + "\n");
}
} catch (Exception e) {
e.printStackTrace();
}
}
Pane pane = new Pane();
Scene scene = new Scene(pane);
pane.getChildren().addAll(ta1,ta2,ta3);
stage.setWidth(1200);
stage.setHeight(850);
stage.setScene(scene);
stage.setTitle("Termine");
stage.show();
stage.centerOnScreen();
}
public static void main(String[] args) {
launch(args);
}
}