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

How can I add combobox in cell table as drag and drop in Java?
Springs 3.6.4 +form bindingerror
extract my java app with its database from netbeans
Dispatcher servlet return unrenderd JSP (Java Config)
JTextArea displaying weird error message
Assign text to JLabels from ArrayList
What does this regex syntax actually mean in Java?
Converting a number to a user chosen base
How to call a stored procedure in JDBC
how to use goto in java
Android - TouchImageView Full view issue
how to get all value checkbox when next pagination (jsp and servlet)
Continue code execution after new JFrame is created and then closed
Handling different soap actions in spring integration
expanding links in the tweets in twitter using twitter 4j
Programatically enabling Mobile data in Android

Categories

HOME
ms-access
deployment
vbscript
blogger
webpack
netsuite
reserved
mean-stack
analysis
paw-app
rdf
installshield
angular-ui-bootstrap
cross-browser
fingerprint
esper
maude-system
adobe-analytics
dax
php-7.1
autoconf
cloudhub
accessor
icloud-api
rundeck
crosstab
qhull
selectedindexchanged
url-scheme
kannel
react-css-modules
brunch
linkerd
primitive
lightswitch-2013
yadcf
exuberant-ctags
avcapturesession
openoffice.org
rotational-matrices
picasso
wpf-controls
jmonkeyengine
webix-treetable
jna
dism
galen
dynamic-reports
google-closure
eigenvalue
revapi
datastax-startup
yii2-extension
setter
spring-mongodb
hittest
vtigercrm
phishing
nsfilemanager
apachebench
phpcas
sdhc
cyclomatic-complexity
drawbitmap
c++03
operator-precedence
id3v2
xojo
expected-exception
hyprlinkr
dexterity
dotnetnuke-5
random-seed
tinn-r
word-processor
venn-diagram
netdna-api
gcj
rfc1123
appendto
inotifycollectionchanged
locate
subviews
gallio
castle-monorail
webkit.net
backcolor
phonon
defensive-programming

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