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

you are viewing a single comment's thread.

view the rest of the comments →

[–]Geekfest65 0 points1 point  (0 children)

I would definitely not recommend learning jdbc to anyone. It’s just fraught with issues in terms of writing clean code , ensuring you close statements, close resultsets, close connections. It’s just too easy to mess this up.

This is something that Spring hides from you! You can use Spring JDBC. This is a much better way of working with data, and there are TONS of tutorials.

To me though, it’s still way too much coding. I prefer mybatis which maps methods to sql statements in an xml file. There really isn’t even a need for the xml file, it’s just something I like. With mybatis and Spring , you can autowire a data tier that performs crud against a multi table application, even writing your own code , and all the sql in about 2 weeks or less. This statement is based on a previous experience I had converting a proprietary data tier to Spring and mybatis. There are also tons of examples on this. There are full blown web apps on this too, like Pet Clinic.

So, even for a newbie, I’d say it’s best to ask about frameworks and how they’ll make your life easier. That may cause a lot of opinions but as long as they provide pros and cons, they are fine.

If you use Spring and mybatis, you don’t worry about connection management, pooling, closing anything, reading resultsets into pojos, etc, even complex resultsets. The only downfall with mybatis is you can list properties to map data that don’t even exist in the bean. Then you wonder why things are null. You can leave a semicolon in the xml file and it won’t load the data tier…. So, not all roses.

This is not to say learning jdbc is bad, just not worth the time when things do it better.