Advertisement
Guest User

Untitled

a guest
Apr 7th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3.  
  4. public void realizaConexion(){
  5. Connection conn = null;
  6. String urlDatabase = "jdbc:postgresql://localhost:0000/midatabase";
  7. try {
  8. Class.forName("org.postgresql.Driver");
  9. conn = DriverManager.getConnection(urlDatabase, "usuario", "password");
  10. } catch (Exception e) {
  11. System.err.println("Ocurrio un error : "+e.getMessage());
  12. }
  13. System.out.println("La conexión se realizo sin problemas! =) ");
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement