Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. package uver;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.ResultSet;
  6.  
  7.  
  8. public class Uver {
  9.  
  10. public static void main(String[] args) {
  11. String url = "jdbc:postgresql://bdd.inf.udec.cl:5432/isw1a";
  12. String usuario = "isw1a";
  13. String contraseña = "matiasmora18";
  14. try{
  15. Class.forName("org.postgresql.Driver");
  16. Connection conexion = DriverManager.getConnection(url,usuario,contraseña);
  17. java.sql.Statement st = conexion.createStatement();
  18.  
  19. /////Pruebas/////
  20. String sql= addNewUser(12121212, "Robert", 1996, 3, 16, 98767698, "Callese Viejo Lesbiano", "arbochanpion@cc.ru", "1234567", true, false, false, false);
  21. st.execute(sql);
  22. ////Fin////
  23.  
  24. /* String sql = "SELECT * FROM uver.login WHERE username = 'dantzig' and pass = 1234";
  25. ResultSet result = st.executeQuery(sql);
  26. while(result.next()){
  27. String id = result.getString("username");
  28. String pas= result.getString("pass");
  29. System.out.println("id: " + id + " pass: " + pas);
  30. }
  31. result.close();*/
  32.  
  33. st.close();
  34. conexion.close();
  35. } catch(Exception e){
  36. System.out.println("ERROR DE CONEXION" + e.getMessage());
  37. }
  38.  
  39. }
  40.  
  41.  
  42.  
  43. ////Métodos////
  44.  
  45.  
  46. public static String addNewUser(int rut, String name, int bornyear, int bornmonth, int bornday, int phone, String description, String mail, String password, boolean smoke, boolean pet, boolean talk, boolean music){
  47. String addNewUser = "INSERT INTO uver.person (rut, fullname, born, phone, description, mail, password, smoke, pet, talk, music) VALUES (" +rut+ ", '" +name+ "', '" +bornyear+ "-" +bornmonth+ "-" +bornday+ "', " +phone+ ", '" +description+ "', '" +mail+ "', '" +password+ "', " +smoke+ ", " +pet+ ", " +talk+ ", " +music+ ")";
  48. return addNewUser;
  49. }
  50.  
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement