Guest User

Untitled

a guest
Nov 26th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. public class Datenbanken {
  2.  
  3. public static void main(String[] args) {
  4.  
  5. String host = "jdbc:derby://localhost:1527/Produkte";
  6. String username = "mitarbeiter1";
  7. String password = "xyz";
  8. int auswahl = -1;
  9. Aktionen aktion = new Aktionen();
  10.  
  11. try {
  12. Connection verbindung = DriverManager.getConnection(host, username, password);
  13. while (auswahl != 0){
  14.  
  15. try {
  16. InputStreamReader isr = new InputStreamReader(System.in);
  17. BufferedReader br = new BufferedReader(isr);
  18. System.out.println("Aktion auswählen");
  19. System.out.println("Produktinformationen anzeigen: 1");
  20. System.out.println("Preis ändern: 2");
  21. System.out.println("Anzahl ändern: 3");
  22. System.out.println("Produkt hinzufügen: 4");
  23. System.out.println("Programm beenden: 0");
  24.  
  25. String eingabe = br.readLine();
  26. auswahl = Integer.parseInt(eingabe);
  27. }
  28. catch (IOException e){
  29. System.out.print("Eingabe nicht möglich.");
  30. }
  31.  
  32. if (auswahl == 1){
  33. aktion.anzeigen(verbindung);
  34. }
  35. else if (auswahl == 2){
  36. aktion.preis(verbindung);
  37. }
  38. else if (auswahl == 3){
  39. aktion.anzahl(verbindung);
  40. }
  41. else if (auswahl == 4){
  42. aktion.hinzufuegen(verbindung);
  43. }
  44. else if (auswahl == 0){
  45. System.out.println("Auf Wiedersehen!");
  46. }
  47. else {
  48. System.out.println("Ungültige Eingabe");
  49. }
  50. }
  51. }
  52. catch ( SQLException err ) {
  53. System.out.println( err.getMessage( ) );
  54. }
  55. }
  56. }
Add Comment
Please, Sign In to add comment