Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Datenbanken {
- public static void main(String[] args) {
- String host = "jdbc:derby://localhost:1527/Produkte";
- String username = "mitarbeiter1";
- String password = "xyz";
- int auswahl = -1;
- Aktionen aktion = new Aktionen();
- try {
- Connection verbindung = DriverManager.getConnection(host, username, password);
- while (auswahl != 0){
- try {
- InputStreamReader isr = new InputStreamReader(System.in);
- BufferedReader br = new BufferedReader(isr);
- System.out.println("Aktion auswählen");
- System.out.println("Produktinformationen anzeigen: 1");
- System.out.println("Preis ändern: 2");
- System.out.println("Anzahl ändern: 3");
- System.out.println("Produkt hinzufügen: 4");
- System.out.println("Programm beenden: 0");
- String eingabe = br.readLine();
- auswahl = Integer.parseInt(eingabe);
- }
- catch (IOException e){
- System.out.print("Eingabe nicht möglich.");
- }
- if (auswahl == 1){
- aktion.anzeigen(verbindung);
- }
- else if (auswahl == 2){
- aktion.preis(verbindung);
- }
- else if (auswahl == 3){
- aktion.anzahl(verbindung);
- }
- else if (auswahl == 4){
- aktion.hinzufuegen(verbindung);
- }
- else if (auswahl == 0){
- System.out.println("Auf Wiedersehen!");
- }
- else {
- System.out.println("Ungültige Eingabe");
- }
- }
- }
- catch ( SQLException err ) {
- System.out.println( err.getMessage( ) );
- }
- }
- }
Add Comment
Please, Sign In to add comment