Skip to content

Database

Cristian Aldea edited this page Mar 15, 2019 · 7 revisions

How to access H2 Database

  1. Run the program
  2. In your browser type "localhost:8080/h2-console
  3. Log in
    • URL=jdbc:h2:./src/main/resources/BaskDB
    • Username = admin
    • Password = vyeAZKyYGRw2P9V
  4. Click on your table on the left and then run the command.

Initial DB Save

    User user = new User();
    user.setName("Admin");
            User user = new User();
    user.setName("Admin");
    user.setUsername("Admin");
    user.setPassword("password");

    User user2 = new User();
    user2.setName("John Doe");
    user2.setUsername("JohnyGotDough");
    user2.setPassword("password");

    User user3 = new User();
    user3.setName("Gandalf the White");
    user3.setUsername("WizardMasterxx");
    user3.setPassword("youshallnotpass");

    UserService.createUser(user);
    UserService.createUser(user2);
    UserService.createUser(user3);

    Tweet tweet = new Tweet();
    tweet.setRetweets(3);
    tweet.setText("I am God! #Hello#LetThereBeLight");
    tweet.setLikes(999);
    tweet.setUser(user);

    Tweet tweet1 = new Tweet();
    tweet1.setRetweets(4);
    tweet1.setText("Welcome to Basilisk #Snake#Cockadoodledoo");
    tweet1.setLikes(888);
    tweet1.setUser(user);

    Tweet tweet2 = new Tweet();
    tweet2.setRetweets(0);
    tweet2.setText("I am eating a bagel and it is delicious #HealthyEating");
    tweet2.setLikes(1);
    tweet2.setUser(user2);

    Tweet tweet3 = new Tweet();
    tweet3.setRetweets(0);
    tweet3.setText("Wow! Donald Trump is some guy ey! #TheWall!");
    tweet3.setLikes(1);
    tweet3.setUser(user2);

    Tweet tweet4 = new Tweet();
    tweet4.setRetweets(5);
    tweet4.setText("You Shall Not Pass! #NotPassing #BYEBalrog");
    tweet4.setLikes(40);
    tweet4.setUser(user3);

    Tweet tweet5 = new Tweet();
    tweet5.setRetweets(5);
    tweet5.setText("Oh shit he grabbed me #IAmNowWhite #SorryFrodo");
    tweet5.setLikes(42);
    tweet5.setUser(user3);

    TweetService.createTweet(tweet);
    TweetService.createTweet(tweet1);
    TweetService.createTweet(tweet2);
    TweetService.createTweet(tweet3);
    TweetService.createTweet(tweet4);
    TweetService.createTweet(tweet5);

    FriendList friendList = new FriendList();
    friendList.setUser(user);
    LinkedList<User> friends = new LinkedList<>();
    friends.add(user2);
    friends.add(user3);
    friendList.setFriendList(friends);
    friendList.setNumberOfFriends(friends.size());

    FriendListService.createFriendList(friendList);

    FriendList friendList2 = FriendListService.retrieveFriendListByUser(user);
    friendList.getFriendList();
Clone this wiki locally