Guest User

Untitled

a guest
Nov 25th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. private String cadenaconecion="jdbc:mysql://127.0.0.1/cafeteria";
  2.  
  3. private String usuario ="root";
  4.  
  5. private String contrasena="";
  6.  
  7. private Connection con =null;
  8.  
  9. public Connection getConnection() throws SQLException
  10. {
  11.  
  12. try {
  13. Class.forName("com.mysql.jdbc.Driver");
  14. con= (Connection) DriverManager.getConnection(usuario, cadenaconecion,contrasena);
  15. } catch (ClassNotFoundException ex) {
  16. Logger.getLogger(conexion.class.getName()).log(Level.SEVERE, null,ex);
  17. }
  18.  
  19.  
  20. return con;
  21. }
Add Comment
Please, Sign In to add comment