I am newbie to Java Spring and learning JDBC template to access database. Now i have 3 relational tables and i need to join them using JDBC template and need to print the result. How can i implement it. Any working example will sure help me a lot.
Thanks
You're really asking a multi-facetated question. I have provided links to of SOs and posts below, but there is many many more answers out there. If these aren't of any use just search for another one there are literally hundreds of posts out there all on the same subject.
you need a query that'll combine three tables into one query (you don't mention if you'll need nested joins, or a simple join three times). For that i suggest you read up on some SQL. Here is a post that will give you an example to a nested select and links to multiple other posts explaining different SQL.
You need to use Spring JDBC (you don't mention which specific template implementation you are using). Here is post that gives you RowMapper examples and the logic to iterate over the results.
you require logic to iterate over the results. This is done most easily with Springs RowMapper or ResultSetExtractor interfaces. Here is a post that'll explain the differences between the two and link to the API (which I recommend you read).
ResultSetExtracor Implementation Example - plus iteration logic
RowMapper Implementation Example - plus iteration logic
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With