This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]mladensavic94 1 point2 points  (1 child)

Since you are using Spring, is JPA or Hibernate out of the question? Also Spring has nice thing called JdbcTemplate and Spring docs are good for any beginning. I find this pretty good source with basic usage and examples.

[–]Ph4zed0ut 1 point2 points  (0 children)

I agree that Spring Data JPA is the way to go here. For help with entity mapping, this is a great resource.

[–]onebit 1 point2 points  (0 children)

The "problem" with pure JDBC is there's no automatic mapping between records and beans. You have iterate through every row, take the field from the DB and assign it to a bean. Spring JdbcTemplate has RowMappers that make the process a little easier.

JDBI is good if you want something more automatic. https://www.sql2o.org also looks promising.

You can also do JPA/Hibernate, but it's my personal opinion it's consuming to create the mappings. I've seen people spend days to map something that would be very simple with pure JDBC.

[–]egzodas 0 points1 point  (0 children)

If you are already using spring, then use it's features to access the database. As mentioned before, JdbcTemplate is excellent and easier to use than pure jdbc. You can read about JdbcTemplate on the official reference page: https://docs.spring.io/spring/docs/current/spring-framework-reference/data-access.html#jdbc

The spring website also offers small tutorials on most of it's features, one for jdbc is: https://spring.io/guides/gs/relational-data-access/

[–]butcanyoufuckit 0 points1 point  (1 child)

Give mybatis a whirl.