Advertisement
Guest User

Untitled

a guest
Aug 11th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.10 KB | None | 0 0
  1.  
  2.     public class DatabaseHelper {
  3.  
  4.     private ConnectionSource connectionSource;
  5.     private Dao<User, Integer> userDao;
  6.     private Dao<Settings, Integer> settingsDao;
  7.     private Dao<Prize, Integer> itemDao;
  8.     private Dao<CulturalCenter, Integer> localDao;
  9.     private Dao<Event, Integer> eventDao;
  10.  
  11.     private static final DatabaseHelper dbHelper = new DatabaseHelper();
  12.  
  13.     public static DatabaseHelper getInstance() {
  14.         return dbHelper;
  15.     }
  16.  
  17.  
  18.     private DatabaseHelper() {
  19.         try {
  20.             this.connectionSource = new JdbcConnectionSource("jdbc:mysql://85.10.205.173/mydb", "myacc", "mypass");
  21.  
  22.             Log.d("Connection", "Do we reach here?" + connectionSource.getDatabaseType().getDatabaseName());
  23.  
  24.             /**
  25.              * DAOS
  26.              */
  27.             this.userDao = DaoManager.createDao(connectionSource, User.class);
  28.             TableUtils.createTable(connectionSource, User.class);
  29.        } catch (SQLException e) {
  30.             e.printStackTrace();
  31.         }
  32.     }
  33.  
  34.     public Dao<User, Integer> getUserDao() {
  35.         return userDao;
  36.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement