Guest User

Untitled

a guest
Dec 7th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1.  
  2. /**
  3. * Beschreiben Sie hier die Klasse datenbank.
  4. *
  5. * @author (Ihr Name)
  6. * @version (eine Versionsnummer oder ein Datum)
  7. */
  8. import java.sql.*;
  9. import java.sql.Statement;
  10. public class datenbank
  11. {
  12.  
  13. Connection c;
  14. Statement stat;
  15. ResultSet r;
  16. datenbank(){try{
  17. Class.forName("com.mysql.jdbc.Driver").newInstance();}
  18. catch(Exception e){
  19. System.out.println(e);
  20. }
  21. try{
  22. c=DriverManager.getConnection("jdbc:mysql://192.168.1.133/pizza?user=mamapizza&password=1234");
  23. } catch (Exception e){
  24. System.out.println(e);}
  25. try{
  26. stat=c.createStatement();
  27. } catch(Exception e){
  28. System.out.println(e);
  29. }
  30.  
  31. }
  32.  
  33. public void Ausgabe(String s, String f, String w)
  34. {
  35. String g=new String("select "+s+" from "+f+" where "+w);
  36. try{
  37. r=stat.executeQuery(g);
  38.  
  39.  
  40. while (r.next()){
  41. System.out.println( s+": "+r.getString(s));}}
  42. catch(Exception e){ System.out.println(e);}
  43. }
  44. }
Add Comment
Please, Sign In to add comment