Advertisement
Guest User

Untitled

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