Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. package controller;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6.  
  7. public class Conexion {
  8.  
  9. Connection conexion;
  10.  
  11. public Conexion() {
  12. conexion = null;
  13. }
  14.  
  15. public String conectar() throws ClassNotFoundException, SQLException {
  16. Class.forName("oracle.jdbc.driver.OracleDriver");
  17. conexion = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "NombreDB", "MiClave");
  18. if (conexion != null) {
  19. return "Conectado";
  20. } else {
  21. return "Sin conexion";
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement