Advertisement
Guest User

Untitled

a guest
Nov 16th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package database;
  7.  
  8. import java.sql.Connection;
  9. import java.sql.DriverManager;
  10. import java.sql.SQLException;
  11.  
  12. /**
  13. *
  14. * @author Tom
  15. */
  16. public class PokemonDA {
  17. private static final String URL = "jdbc:mysql://localhost/pokemon";
  18. private static final String USER = "tom";
  19. private static final String PWD = "tom";
  20.  
  21. private Connection connection;
  22.  
  23. private static PokemonDA instance;
  24.  
  25. public static PokemonDA getInstance(){
  26. if( instance == null){
  27. instance = new PokemonDA();
  28. }
  29.  
  30. return instance;
  31. }
  32.  
  33. private void initConnection(){
  34. try{
  35. Class.forName("com.mysql.jdbc.Driver");
  36. connection = DriverManager.getConnection(URL, USER, PWD);
  37. }
  38. catch(ClassNotFoundException e){
  39. e.printStackTrace();
  40. }
  41. catch(SQLException e){
  42. e.printStackTrace();
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement