In this tutorials will teach you Java connect with MongoDb Database with Swing Application.MongoDb is a NOSQLdatabase.how to do the simple registation form connect with MongoDb Database teach step by step here.How to connect java in to MongoDb Database.
Establish the database Connection with Java and MongoDb Database
First Install the mongodb and robo mongo i attched the video link below.
If you don’t have a idea about MongoDb Database . it is simple to learn i have attached the video link below.
After watch above video links i hope now you have clear idea about mongodb.
mongo = new MongoClient(“localhost”,27017); This is port where your robo mongodb is connected
dbconnection = mongo.getDatabase(“school”); This is database name
collection= dbconnection.getCollection(“records”); This is a table name
MongoClient mongo; MongoDatabase dbconnection; MongoCollection<org.bson.Document> collection; public void Connect() { mongo = new MongoClient("localhost",27017); dbconnection = mongo.getDatabase("school"); collection= dbconnection.getCollection("records"); System.out.println("connect"); }
after done the connet() method call inside the constructor of the class
public Registation() { initComponents(); Connect(); }
Paste the Code Inside the Save Button
Document d =new Document("name",txtName.getText()); d.append("age",txtAge.getText()); d.append("course",txtCourse.getText()); collection.insertOne(d); JOptionPane.showMessageDialog(this, "Inserted Successfully");
This article explain how to make a Fish Inventory Management App in Angular.this app explain…
Introduction to Fish Inventory Management In the aquaculture industry, managing fish inventory is crucial for…
Introduction to Java GUI CRUD Java is a powerful programming language widely used for building…
Introduction to Login Form Design Designing an effective and beautiful login form is crucial for…
Introduction In today creating a responsive login form is essential for providing a seamless user…
Introduction to Inventory Management Systems In today's fast-paced digital environment, businesses require efficient inventory management…