Guest User

Untitled

a guest
Jul 6th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.39 KB | None | 0 0
  1. System.out.println("MySQL Connect Example.");
  2. //        Connection conn = null;
  3. //        String url = "jdbc:mysql://127.0.0.1:3306/";
  4. //        String dbName = "test";
  5. //        String driver = "com.mysql.jdbc.Driver";
  6. //        String userName = "root";
  7. //        String password = "root";
  8. //        try {
  9. //            Class.forName(driver).newInstance();
  10. //            conn = DriverManager.getConnection(url + dbName, userName, password);
  11. //            System.out.println("Connected to the database");
  12. //
  13. //            try {
  14. ////                Statement st = conn.createStatement();
  15. ////                int val = st.executeUpdate("INSERT INTO Korisnik (Ime, Prezime) VALUES('','');");
  16. //                preparedStatement = conn.prepareStatement("INSERT INTO Korisnik (Ime, Prezime) VALUES ( ?, ?)");
  17. //                preparedStatement.setString(1, Ime_tf.getText());
  18. //                preparedStatement.setString(2, Prezime_tf.getText());
  19. //                preparedStatement.executeUpdate();
  20. //                System.out.println("1 row affected");
  21. //            } catch (SQLException s) {
  22. //                s.printStackTrace();
  23. //                System.out.println("SQL statement is not executed!");
  24. //            }
  25. //
  26. //            conn.close();
  27. //            System.out.println("Disconnected from database");
  28. //        } catch (Exception e) {
  29. //            e.printStackTrace();
  30. //        }
Add Comment
Please, Sign In to add comment