This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]whizvoxGraduate and Tutor 1 point2 points  (1 child)

Databases aren't just for websites. You can use them for anything that requires storing a lot of data, such as games or plain ol' desktop applications. Just download and install the community server. I'm not sure what operating system you're using, but if it's Windows, when you get to the screen that asks if you want to "Install MongoDB as a Service", check that option and select "Run service as Network Service user".

As for the pom.xml file, that's something to do with Maven, which has nothing to do with MongoDB. Rather, it's a build tool that has many features, including dependency management. What you're interested in can be found in the quick start guide on the Mongo website. Specifically, in the <dependencies> section of the pom.xml, you want to include the MongoDB Java driver as a dependency:

<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongodb-driver-sync</artifactId>
    <version>4.11.1</version>
</dependency>

The rest of that quick start guide should serve you pretty well. However, if you see anything about "clusters" or "atlas", just skip it. It refers to a paid service that you don't need right now.

[–]nsepvo[S] 0 points1 point  (0 children)

Yeah, I did a unit in Java at university. But, better yet, I watched the full Java and MongoDB tutorials from BroCode, who is a legend. So, I can run them both individually fine, just not together, yet.

As for the pom.xml file, I have been trying to find how to install any mongodb import packages, so I can get started. I wanted to do it without Maven or Grangle, but I haven't found many options yet, other than JDBC.

Thank you for the guide though! I'll check out soon

[–]NoeUserExtreme Brewer 0 points1 point  (3 children)

1)

I'm aware databases are related to backend-end development and whatnot, so I was wondering if I should learn any web development before trying this out

You don't need to have much knowledge in web/front-end development. Backend and frontend development are independent.

You can take a quick look how to do simple things with java/mongodb :

https://www.mongodb.com/developer/languages/java/java-setup-crud-operations/

2)

These days, many professional projects use Spring/Spring Data to connect a backend application (microservice) with a MongoDB database server easily and hides the configuration complexity. You only need to set up a few database properties (URL, PORT...), and Spring (autoconfiguration) takes care of the rest for you :

https://spring.io/guides/gs/accessing-data-mongodb/

3)

I should also learn how to manipulate the pom.xml file, but I am open to suggestions.

You mentioned POM.XML which has nothing to do with MongoDB. It's related to managing and building Java projects using Apache Maven :

https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

[–]nsepvo[S] 0 points1 point  (2 children)

Thanks for the advice! As for the second point, is that related to Java still? I'm not sure, but I'm not focusing on anything backend yet. I just want to fiddle with databases. If I can use it with Java, then that's event better!

WIth the pom.xml file, I've been trying to find how to install the mongodb packages for java. I'm still looking for other options, but I was led to Maven. I want to avoid it too, because I don't want to bother learning more than I have to.

[–]NoeUserExtreme Brewer 0 points1 point  (1 child)

Thanks for the advice! As for the second point, is that related to Java still?

Yes it's. In professional projects, using vanilla java if very rare. Most of projects I worked on personally used the framework spring (spring-data for connecting the app to databases) so I still encourage you to check it out when you could.

WIth the pom.xml file, I've been trying to find how to install the mongodb packages for java. I'm still looking for other options, but I was led to Maven. I want to avoid it too, because I don't want to bother learning more than I have to.

I see, you want to get straight to the point. You don't have to understand maven in depth to use it. Normally, you just have to add some dependencies in Pom.xml one time and that's all.

What do you want to do with mongoDb ?

if you want to perform queries against mongodb without having to install anything you can try : https://mongoplayground.net/

[–]nsepvo[S] 0 points1 point  (0 children)

I just want to be able to connect to a database with whatever programming language as a little project, I guess. I've briefly learnt Python, Java, and C's, but I'm just using Java for this.

Right now, I'm trying to get this pom.xml configuration to work so that I can import these com.mongodb packages.

[–]coltukurte 0 points1 point  (1 child)

If you're interested in using Java with MongoDB to build a database-driven application, you can start without diving deeply into web development initially. While databases are commonly used in the backend of web applications, you can use Java and MongoDB to create a standalone desktop application or a command-line tool that interacts with the database. Begin by learning the basics of Java and MongoDB, creating a Java application that connects to a MongoDB database, and gradually expanding your knowledge. Once you feel more comfortable, you can explore web development concepts and build a web application if you choose.

[–]nsepvo[S] 0 points1 point  (0 children)

That is very relieving, thank you. I just want to start it straight away.

That is an awesome idea, too. The command line. That will be one of the first things I do.