Share your repls and programming experiences

← Back to all posts
ReplDBManager || A Java Client For ReplDB
EpicGamer007 (1635)

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 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:

ReplDBManager client = new ReplDBManager(System.getenv("REPL_DB_URL"));

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:
Map<String, String> toAdd = new HashMap<String, String>();

toAdd.put("KEYONE", "AVALUE");

  • 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:

client.setValue("SPACE TEST", "What will happen to this because of the spaces?");


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 packages are only a part of hava 11

amaddentcsec (235)

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

EpicGamer007 (1635)

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

EpicGamer007 (1635)

@amaddentcsec, yea u need to change the java version

EpicGamer007 (1635)

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

Jakman (450)

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 (1635)

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

Edit: It's a lot of google too.

Jakman (450)

@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 (1635)

@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 (450)

@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 (1635)

@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 (835)

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

EpicGamer007 (1635)

@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

EpicGamer007 (1635)

@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().

Scoder12 (835)

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

EpicGamer007 (1635)

@Scoder12, method and constructor overloading is amazing

SixBeeps (5067)

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

EpicGamer007 (1635)

@SixBeeps, good luck to you as well!