Advertisement
Patasuss

DataConnect

Jan 5th, 2016
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. package com.journaldev.jsf.util;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5.  
  6. public class DataConnect {
  7.  
  8. public static Connection getConnection() {
  9. try {
  10. Class.forName("org.apache.derby.jdbc.ClientDriver");
  11. Connection con = DriverManager.getConnection(
  12. "jdbc:derby://localhost:1527/PataDB", "APP", "APP");
  13. return con;
  14. } catch (Exception ex) {
  15. System.out.println("Database.getConnection() Error -->"
  16. + ex.getMessage());
  17. return null;
  18. }
  19. }
  20.  
  21. public static void close(Connection con) {
  22. try {
  23. con.close();
  24. } catch (Exception ex) {
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement