Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Which one is better, "Database Connection using JSP or Java"  RSS feed

 
Srinivas Genji
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which one is better approach for Database connection, writing code for DBConnect in Java and importing the class in JSP or writing DBConnect in JSP itself.
Any Help is much appreciated
Thanks in Advance
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Obviously a class written in Java would be better, make a Connection Pooling mechanism, & get the database object from Connection Pool in your JSP pages.

Then you need not worry about making connection everytime the JSP's are accessed & saves on overloading of the DB engine.

hth
MB
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP is Java.

I'd have a look at the DAO pattern, which is a well recognized pattern for using JDBC in Java applications.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What they said...

Plus, your display name needs to be changed... We don't have many rules around the 'Ranch, but we do require your display name to follow the JavaRanch Naming Policy.
You can change it here.

Thanks! and welcome to the JavaRanch!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!