Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Connection myCon;
- try{
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- // Connect to an instance of mysql with the follow details:
- // machine address: pc236nt.napier.ac.uk
- // database : gisq
- // user name : scott
- // password : tiger
- myCon = DriverManager.getConnection(
- "jdbc:mysql://localhost:3306/kundenverwaltung",
- "root","");
- }
- catch (Exception sqlEx){
- System.err.println(sqlEx);
- }
- }
- public void kundenAnzeigen(){
- Statement myStmt;
- try {
- myStmt = myCon.createStatement();
- ResultSet result = myStmt.executeQuery("SELECT * FROM kunde");
- while (result.next()){
- System.out.println(result.getString("name"));
- }
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement