Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. public class Conexion {
  2. private Statement statement;
  3.  
  4.  
  5. public Conexion() {
  6. }
  7.  
  8. public Connection getConexion() throws ClassNotFoundException {
  9. Connection con = null;
  10. try {
  11. /* Carga|Registra el driver JDBC */
  12. Class.forName("com.mysql.jdbc.Driver");
  13. /* Obtener la conexion */
  14. con = DriverManager.getConnection("jdbc:mysql://localhost:3306/pruebamini","root","");
  15. setStatement(con.createStatement());
  16. } catch (SQLException ex) {
  17. System.out.println("No se pudo conectar");
  18. }
  19. return con;
  20. }
  21.  
  22. public Statement getStatement() {
  23. return statement;
  24. }
  25.  
  26. public void setStatement(Statement statement) {
  27. this.statement = statement;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement