Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 + JDBC: Good or Bad?

 
Kat Rollo
Ranch Hand
Posts: 62
Eclipse IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For a school project, my group is planning to use Struts2 with plain JDBC/SQL for database. The database is expected to have around 1000 records (or less).
The Struts2 is pretty much set. However, is it a good choice to use plain JDBC/SQL or go with Hibernate instead?
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since this is a school project, provided if you are already familiar with JDBC, ResultSet handling and so on, I'd invest in learning a new technology. If you have not worked with Hibernate, this should be the right time to do so.
 
Kat Rollo
Ranch Hand
Posts: 62
Eclipse IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response. Is plain JDBC/SQL no longer used in the outside world?
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as my experience goes, I see one or the other object relational mapping framework used instead of JDBC.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kat Rollo wrote: Is plain JDBC/SQL no longer used in the outside world?


It's still used in a lot of applications. However, the JDBC logic is usually wrapped by a layer on top of it, to reduce the connection, query and result set management. That layer could be something that's simple and developed specific for that application or it could be as big and complex as ORM frameworks. Either way, JDBC is still used and having a sound knowledge about those APIs and their usage, especially if you haven't used it before, is definitely going to help you improve your basics.
 
Kat Rollo
Ranch Hand
Posts: 62
Eclipse IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Honestly, I'm a bit scared to touch Hibernate. There seems to be a lot going on under the hood and it might be too powerful for someone just beginning JavaEE and frameworks.
I personally like managing my own SQL statements and closing my own resources.
But it seems there are a lot of job offers with Hibernate.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You still have to close your Hibernate sessions just like how you close your JDBC connections. It is just not that. With Hibernate or rather with any ORM framework, you work with your domain objects rather than populating your domain object from the ResultSet.

There is nothing to scare. If you are able to understand JDBC, Hibernate should be easy for you to pick up!
 
Kat Rollo
Ranch Hand
Posts: 62
Eclipse IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey thanks, I do agree it's a good investment.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3165
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Off late I have been working with iBatis and Struts. The good thing I found about iBatis was that I could define my queries, provide them an identifier and then I can also provide a custom result mapper or just use HashMap. So you can check that out as well.

I have also worked with Spring JdbcTemplate which is also good, so you can do connection pooling, write your queries, provide result set mappers to iterate through the result set and populate your objects. This way you have more control over the interaction with DB.

My experience has been that learning a technology/framework on the job is quite easy. If you are a skilled developer then it shouldn't be a problem to pick any technology.

ORM mappers build this complete object graph if I am not wrong i.e populating the composite object data by using the relationships between the tables. Is it not that ORM mappers are very helpful while your are doing CRUD on your domain objects and while you are writing a very complex query there are chances of getting lost while using ORM Query Language?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic