Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. Class.forName("com.mysql.jdbc.Driver");//Cargar el driver
  2. Connection conexion = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/agenda","root", ""); //Primer ejemplo Nombre de la BD, Segundo ejemplo Usuario, Tercer ejemplo Clave.       
  3.  
  4. Statement sentencia = conexion.createStatement();
  5.  
  6. sentencia.executeQuery ("SELECT * FROM contactos WHERE nombre='" + contacto[0] + "' and apellidos='" + contacto[1] + "';");
  7.  
  8. sentencia.executeUpdate ("UPDATE contactos SET tlf='" + contacto[1] + "' WHERE codigo=" + contacto[0] + ";");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement