Advertisement
Guest User

Untitled

a guest
May 4th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. /**
  2.  *
  3.  */
  4.  
  5. /**
  6.  * @author pedro
  7.  *
  8.  */
  9. import java.sql.*;
  10. public class CopyOfHolaMundoBaseDatos2 {
  11.   public static void main(String[] args)
  12.      throws ClassNotFoundException, SQLException {
  13.        
  14.     Class.forName("com.mysql.jdbc.Driver");
  15.                
  16.     Connection conn = DriverManager.getConnection(
  17.         "jdbc:mysql://localhost:3306/sample","root","");
  18.  
  19.     //Statement stmt2 = conn.prepareStatement("INSERT INTO autores VALUES (3,'Pepe','Española'");
  20.    
  21.     Statement stmt = conn.createStatement();
  22.     int rs = stmt.executeUpdate(
  23.         "INSERT INTO autores VALUES(3,'Pepe','Española' ");
  24.        
  25. //  while (rs.next()) {
  26. //      String name = rs.getString("nombre");
  27. //     
  28. //      System.out.println(name);
  29. //  }
  30. //  rs.close();
  31.     stmt.close();      
  32.     conn.close();
  33.   }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement