Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. import java.sql.*;
  2. import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
  3. public class Mein {
  4.  
  5. public static void main(String[] args) {
  6. try
  7. {
  8. Class.forName("com.mysql.jdbc.Driver");
  9. Connection conexion = DriverManager.getConnection
  10. ("jdbc:mysql://localhost/Mia", "root", "Namdi.31");
  11. Statement s = conexion.createStatement();
  12. // s.executeQuery ("INSERT INTO usuarios VALUES('saul','123'); ");
  13. PreparedStatement a =null;
  14. a= conexion.prepareStatement("INSERT INTO usuarios VALUES('saul','123'); ");
  15. a.executeUpdate();
  16. ResultSet rs = s.executeQuery ("SELECT * FROM usuarios ");
  17.  
  18.  
  19.  
  20. while (rs.next())
  21. {
  22. System.out.println (rs.getString (1) + " " + rs.getString (2));
  23. }
  24. }
  25. catch (Exception e){
  26. e.printStackTrace();
  27. System.out.println("ERROR");
  28. }
  29. }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement