Hey! As you're reading this, you know that I returned from Italy. It was very nice, but okey - you want to create users database for your bot. Disputes about what DB is better can live very long time, but I will choose MongoDB. It is high-performance, schema-free document-oriented database. Let's create actual 'body' of our bot. Well, as always. I will skip this step as I know you have your own bot and there is no need to pollute the great lesson unnecessary amount of code. If not, you can find all sources at GitHub repo. Now, import MongoDB's driver for Java. You can download it here or import it from Maven. With IntelliJ Idea it is easier than you expect. Just go to File < Project Structure... < Libraries < + < From Maven and search for org.mongodb:mongo-java-driver. That's all. Import it in your bot file:
You will also need org.slf4j:slf4j-nop library to disable additional logging, like this:
11:01:15.406 [pool-1-thread-1] DEBUG org.mongodb.driver.protocol.query - Query completed
11:01:25.174 [cluster-ClusterId{value='554dbecb1b554f11e86c3a69', description='null'}-localhost:27017] DEBUG org.mongodb.driver.cluster - Checking status of localhost:27017
Install it from Maven as you did with MongoDB Java Driver. Let's write our "check" function, that will check if user exists in database. If not, write it.
Replace host:port with your Mongo's host and port. You can find how to setup MongoDB server for Ubuntu here. Then we set our database and collection. Replace this names with your own.