Advertisement
Guest User

Untitled

a guest
Jul 6th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. import java.sql.*;
  2. public class DbConnection {
  3. Connection con;
  4. Statement st;
  5. DbConnection(){
  6. dbconnect();
  7. }
  8. //-----------------------
  9. public void dbconnect(){
  10. try
  11. {
  12. Connection conn=DriverManager.getConnection("jdbc:ucanaccess://C:/Users/Ghazi/workspace/java w access/login.accdb");
  13. Statement stment = conn.createStatement();
  14. }
  15. catch(Exception err)
  16. {
  17. System.out.println(err);
  18. }
  19. }
  20. //--------------------------
  21. public static void main(String[]args){
  22. DbConnection ob=new DbConnection();
  23. }//end main
  24. }
  25.  
  26. public void dbconnect(){
  27. try {
  28. Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
  29. Connection conn=DriverManager.getConnection("jdbc:ucanaccess://C:/Users/Ghazi/workspace/java w access/login.accdb");
  30. Statement stment = conn.createStatement();
  31. }
  32. catch(Exception err) {
  33. System.out.println(err);
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement