Share your repls and programming experiences

← Back to all posts
ReplDBManager || A Java Client For ReplDB
h
EpicGamer007

ReplDBManager V 1.0

ReplDBManager is a client for replers to use to easily manage the Database in their java repl project.

This was created by @AbhayBhat

The creator has also received help from:

  • @Scoder12 - Helped with getting data from the Database(Setting up the network connection)
  • @Coder100 - Also helped with getting data from the Database(Setting up the network connection)
  • @Jakman - Helped with Testing and feedback
  • @SixBeeps - Helped with fixing and improving the client

Setting up ReplDBManager:

As of V 1.0, the only ways to get ReplDBManager into your repl currently is to fork this repl or copy-pasting the code in a file called ReplDBManager.java. Source can be found here.

A jar is planned to come out shortly.

Using the Class

Setting it up in your project

Declaring the Client is like so:

Pass in the url to your repl database by by using System.getenv().

If you are using this on your os, remember to get the link from here then use it from your computer because REPL_DB_URL will most likely not be one of your environment variables already

Noteable Instance variables

  • boolean toUpper - If true, all new key-value pairs will be converted to uppercase before going into the database. Set to false by default

Using it's methods

IT IS IMPORTANT TO NOTE THAT THESE METHODS ALL throws IOException, InterruptedException

The available methods in ReplDBManager as of V 1.0 is:

  • void setValue(String key, String value) - sets the key to value in the database. If key is not already present, it will be created
  • void setValues(Map<String, String> things) - sets all the key's in the Map to the value's in the map. Example:
  • String getValue(String key) - returns the value associated with the key
  • String[] getKeys() - returns all keys in the database
  • HashMap<String, String> getAll() - returns every key with every value associated with the key
  • void deleteValue(String key) - deletes the value associated with the key and the key from the database
  • void deleteValues(String[] keys) - deletes all the values associated with the keys and the key from the database
  • void deleteAll() - Deletes ALL the key-value pairs from the database
  • void setToUpper(boolean newB) - sets the toUpper variable to newB
  • boolean getToUpper(boolean newB) - gets the variable toUpper

Notes: If parameters passed to any of the setValue methods contain a ' ', it will be converted to '-'. Example:

Will print:

That is all. I hope y'all enjoy it.

Happy Coding :D

Edit: Added no-arg constructor which initializes url to database with System.getenv("REPLIT_DB_URL");.
Edit: You need Java 11 for this to work. The java.net.http packages are only a part of hava 11

Voters
Pwn3rz
ChristopherHave
lfny
plscodeinjava
cosmidqu
SwaroopBappanad
mkhoi
Jakman
SelenaYang1
SixBeeps
Comments
hotnewtop
EpicGamer007

FOR ANYONE READING THIS AFTER 6/15/2021, THE ORIGINAL REPLDBMANAGER HAS BEEN DELETED, PLEASE DIRECT YOURSELVES TO https://replit.com/@EpicGamer007/ReplDBClient

plscodeinjava

@AbhayBhat
I need help with this, I am getting an error:

EpicGamer007

@amaddentcsec, you have to use java 11. reload the tab and tell me which version of java it says

EpicGamer007

@amaddentcsec

It should look like this:

plscodeinjava
plscodeinjava
EpicGamer007

@amaddentcsec, yea u need to change the java version

plscodeinjava

@AbhayBhat
How though?

plscodeinjava

@AbhayBhat
Can you help me with this?

EpicGamer007

@AbhayBhat, sorry, online class rite now :( maybe later. Try searching it up though or ask in ask

Jakman

Good job. You are almost at my level. You are doing amazingly. You've grown so much since i first started teaching you. I want you to beat me in the knowledge of java.

EpicGamer007

@Jakman, wait, when did u decide ur better than me? lol

Edit: It's a lot of google too.

Jakman

@AbhayBhat i remember teaching you some basics just a few months ago.
Helping you with the concepts. I can see though that you are challenging my skill. And i can see that one day you will know more about java than me

EpicGamer007

@Jakman, ok... But i mean, by basics. What exactly do u mean, when i signed up for repl, i already had a good grasp on the basics.

Jakman

@AbhayBhat Not exactly basics. Really just cool tech that you could use to your advantage. I also remember helping you with the private and protected keywords.

EpicGamer007

@Jakman, oh yea, thanks for that :D. It just.. my pride wont let me think that i was worse than u, uhhhhhhhh. sorry, just venting on repl

Scoder12

Maybe you should be able to construct with no arguments and it will use the environment variable for you.

EpicGamer007

@Scoder12, that is possible but the problem with that is what if someone is using theis from their own computer?(Most people probably won't but there is a chance). Then the environment variable would not be there, and there is a chance it could break, this way, someone could get a link from one of their repls doing something like echo $REPLIT_DB_URL, get the link, then paste it when initializing the variable making it accessible even when you are not on repl.it

EpicGamer007

@Scoder12, I guess I can add a no-arg constructor so that if there is no link initialized, it will just automatically do System.getenv().

EpicGamer007

@Scoder12, added.

Scoder12

@AbhayBhat Thats why you keep the current constructor as well. You can have both.

EpicGamer007

@Scoder12, method and constructor overloading is amazing

Coder100

nice!! C# time

EpicGamer007

@Coder100, good luck!

Coder100
SixBeeps

@Coder100 I'll make one that's better than yours good luck with that!

EpicGamer007

@SixBeeps, good luck to you as well!

k9chelsea2

nice

EpicGamer007

@k9chelsea2, thanks!