java


How to install and connect MongoDb in Netbeans?


I'm using the MongoDB Java driver in a Java web app. Whenever I'm doing a query, or can I keep it open and run other queries on it and close it when my application ends?
You should create DAL object which will handle low level Database CRUD operation,
And this object will be singleton as "Piu" suggested.
All the methods inside of this object will handle creating/opening/closing connection (on application Exit).
This way you will in future you will be free to change to other DB solution and change only the DAL class.
On your question, in my opinion you should leave the connection open if you will communicate with the DB a lot. But if you will need to access to DB once a you start the application and on exit and the application execution duration is not short it is safe to close and reopen the connection.
When you create an instance of class MongoClient. Your connection will keep by default. It only close when you use method close() to close it. If you want to open and run other query on it (all query will reuse this connection), you can use the pattern singleton to create only one instance of MongoClient. This pattern will re-create your connection if it is null.

Related Links

What methods should be contained in the DAO? [closed]
How to build multi dex into apk by maven?
Stream videos in client app using Ajax and java Restlet
Am able to store the image in my computer drive. but unable to display on page
How can I use threads in standard JAX-RS?
Spring 4.0 Jquery Ui autocomplete 406 Not Acceptable Error
Priority of ActiveMQ configuration via URI
Quartz or java timer service for database polling
Method execution after fields are initialized
Lambda expression in Iterable implementation
How to sort books in java [closed]
List files in a package from Android App returns null
Hibernate and MySQL connection - java.net.ConnectException: Connection refused: connect. The driver has not received any packets from the server
Java Swing getvalue from combobox object
JFileChooser hangs the application
Java Android Sockets Threading

Categories

HOME
ibm-bluemix
keras
microservices
rubygems
c#-2.0
jpeg
applepay
here-api
zend-framework3
fallback
try-catch
django-simple-history
libtiff
windows-7-x64
jqwidget
cx-freeze
kudan
microsoft-r
crystal-reports-2010
react-css-modules
virtualdub
tooltipster
libuv
kendo-datasource
nouislider
stormpath
siesta-swift
calibre
caret
asset-pipeline
uiswipegesturerecognizer
serve
lto
hockeyapp
sharefile
optix
avro4s
checkboxlist
fault
qsslsocket
yii2-extension
directory-structure
nbconvert
django-scheduler
redundancy
google-cdn
grails-tomcat-plugin
removechild
azure-virtual-network
prettytensor
essence
netmq
unity-networking
reactive-banana
lemon
marching-cubes
angular-leaflet-directive
android-listview
method-parameters
remobjects
clipperlib
umbraco6
bigbluebutton
codeigniter-routing
asp.net-web-api-odata
terminfo
castle
valuechangelistener
mechanize-ruby
multiprocessor
dexterity
gridcontrol
hungarian-algorithm
yui-compressor
factory-method
gdata-api
uiviewanimation-curve
transactionscope
f#-powerpack
celltable
dmx512
gamma
suppress
asp.net-profiles
web-architecture
temporal-database
mediarss
data-acquisition
commodore

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App