Guest User

Untitled

a guest
Jul 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3. import javax.swing.JOptionPane;
  4.  
  5. public class Pasesdesalidas {
  6.  
  7. static Connection con = null;
  8. static String driver ="net.ucanaccess.jdbc.UcanaccessDriver";
  9. static String url = "jdbc:ucanaccess://C:\Users\INFORMÁTICA&SISTEMAS\Documents\DataBase\Pases de salida.accdb";
  10.  
  11. public static Connection obtenerConexion() {
  12. try {
  13. if(con==null) {
  14. Class.forName(driver);
  15. con= DriverManager.getConnection(url);
  16. JOptionPane.showMessageDialog(null,"Conexion correcta");
  17. }
  18.  
  19. }catch(Exception ex) {
  20. ex.printStackTrace();
  21. con = null;
  22. }
  23. return con;
  24. }
  25. public static void main(String[]arg) {
  26. Connection cn = Pasesdesalidas.obtenerConexion();
  27. }
  28. }
Add Comment
Please, Sign In to add comment