Skip to content
← Back to Community
JavaDB - ReplDB Client for Java!
Profile icon
AmazingMech2418

JavaDB

Welcome to JavaDB. JavaDB is a ReplDB API for the Java programming language! This helps you create databases for your Java repls!

Setup

To set up JavaDB in your repl, just copy all of the files in the JavaDB folder. Also, you should preferably copy README.md to give proper credit, but feel free to rename it. Repl.it will automatically compile the package, so don't worry about compiling it yourself!

Usage

To use JavaDB, you first need to use the following import command:

import repl.it.amazingmech2418.javadb.*;

You also need the following for error catching:

import java.io.IOException; import java.net.MalformedURLException;

You also need to include in any methods you use JavaDB in throws IOException, MalformedURLException unless you use try...catch.

Then, you need to go to your main method and create your ReplitDBHandler object.

ReplitDBHandler db = new ReplitDBHandler();

You could also specify a URL as a parameter for the constructor.

Now, you can use db to modify your database.

Getting a list of keys

To get a list of keys, you first need to import java.util.ArrayList. Then, you create an ArrayList of strings that is set to db.getKeys(). Then, you can use ArrayList methods to use this data. You could also just directly print the value as is done in this demo repl.

Getting a key's value

To get a key's value, you simply use db.getKey("yourkey"). The key must be present in the database or an error will be thrown. The key name, however, can include any unicode characters.

Setting a key's value

To set a key's value, you simply use db.setKey("yourkey", "yourvalue"). If the key does not exist, this will create it. The key name and value can contain any unicode characters you wish.

Deleting a key

To delete a key, you simply use db.deleteKey("yourkey"). Like with getting a key's value, the key must already be in the database.

Credits

Thank you @EpicGamer007 and @amaddentcsec for inspiring this with your own ReplDB client and JavaSocial respectively!

Voters
Profile icon
plscodeinjava
Profile icon
EpicGamer007
Profile icon
elipie
Profile icon
AmazingMech2418
Comments
hotnewtop
Profile icon
EpicGamer007

YAY :DDD Good job this is really cool! This is also much shorter than mine so good job on that(but your's does cut a little short on features)!

Profile icon
AmazingMech2418

@EpicGamer007 Thank you! Though, what kinds of features exactly? LOL! Does yours have like a quasi-SQL or JSON system?

Profile icon
EpicGamer007

@AmazingMech2418 , non no no. i dont mean it that way, just add a few more methods, like a method to set multiple keys, or get multiple keys by their prefix, etc.

Profile icon
AmazingMech2418

@EpicGamer007 Oh! That makes sense! LOL!

Profile icon
EpicGamer007

@AmazingMech2418 ,lol, also, u said in the achievements announcement that ya wanna work on a multiplayer thing, do you have any ideas?

Profile icon
AmazingMech2418

@EpicGamer007 I'd be fine with any language. Though, I don't have to many ideas for the actual project. LOL!

Profile icon
Umar-FaruqAkinw

Wow This is really cool but I am just wondering. Can Repls share one database??

Profile icon
AmazingMech2418

@Umar-FaruqAkinw Repls cannot natively share a database, but you can create a server to link multiple repls to the same database.

Profile icon
Umar-FaruqAkinw

@AmazingMech2418 Okay is there anywhere I can find how t do this

Profile icon
Umar-FaruqAkinw

@AmazingMech2418 Oh I see. Where do I find the instructions to get this to work.

Profile icon
AmazingMech2418

@Umar-FaruqAkinw Well, there isn't any specific tutorial, but you can just create an API endpoint on a server repl to share the DB.

Profile icon
AmazingMech2418

@Umar-FaruqAkinw Well, there aren't any instructions on how to get this to work.

Profile icon
nehaadmec

Java is an important language to learn for a web designer too. By going for web design courses, one can learn Java along with other programming languages to make the basics of codding clear.

https://www.admecindia.co.in/courses/web-design-courses-delhi/

Profile icon
kunallomesh

web development is an interesting field, with bright future scope, if you want to learn then join
web development course in Delhi :https://www.admecindia.co.in/course/best-web-development-master-course/

Profile icon
gauravpant
Profile icon
mahimamantri

Great post. Thanks for sharing. Sevenmentor offers the best Java course in Pune from industry experts to develop conceptual knowledge of coding with placement assistance. https://www.sevenmentor.com/java-training-classes-in-pune.php