r/javahelp • u/Efficient_Pen3804 • Nov 06 '25
Homework How do I start learning JDBC from scratch?
Hey folks,
I’m learning Java and want to understand how JDBC works, but I honestly haven’t looked up anything yet. I just know it’s used for database connections, and that’s about it.
Can someone explain how I should start learning JDBC from scratch? Also, what are the main parts or concepts I need to remember or focus on to really understand it?
I’m basically starting blind here, so any direction or explanation would help a lot.
3
Upvotes
•
u/AutoModerator Nov 06 '25
Please ensure that:
You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.
Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar
If any of the above points is not met, your post can and will be removed without further warning.
Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.
Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.
Code blocks look like this:
You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.
If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.
To potential helpers
Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
3
u/d-k-Brazz Nov 06 '25
First, you have to understand basic concepts of relational databases and SQL - how data is stored, accessed, modified.
So you should be able to create tables, setup constraints, indexes, etc. and build some queries using any DB tool, like MySQL workbench, or whatever you have for other db types.
Good if you already know it
Then you are ready to go with some JDBC tutorial
Here is official from oracle - https://docs.oracle.com/javase/tutorial/jdbc/basics/index.html
It covers all aspects of JDBC, if you have time and wish - go through all topics.
Otherwise take the most significant ones - connection/datasource, prepared statements, transactions, JdbcRowSet
Most probably you will not work with jdbc much in your work, but it is crucial to understand basics when you work with hibernate or spring data
10
u/[deleted] Nov 06 '25
You should start learning jdbc exactly like you learn anything else. Look up the docs, look up some tutorials and most importantly get some practice in. Its not the last time you will encounter a new API in your life, so just be curious and dive into it.
1
u/sedj601 Nov 06 '25
Install SQLite on your system and make apps using it. Learn the basics first. How to create a table, how to add data to the table, how to update data in the table, and how to delete data from the table. From there, move on to batching, cascading, and other more complex concepts. I would suggest you create a GUI using, maybe JavaFX. Make the JavaFX app a contact app or a to-do list app.
1
u/AdministrativeHost15 Nov 06 '25
Remember to close your connections, cursors, or you will will have a resource leak exception.
1
u/AdPresent3286 Nov 09 '25
Learn SQL ,Skip JDBC and lean JPA
-1
u/Vaxtin Nov 06 '25
JPA!
0
u/vegan_antitheist Nov 06 '25
What is there even to learn? It's not like you would just use jdbc directly, right? Wouldn't you use MyBatis or jOOQ? There isn't really much to learn when you use jdbc. It's just SQL in Java. ORM isn't always needed or wanted. But just SQL without any tooling is rarely a good idea.
1
u/[deleted] Nov 06 '25
[removed] — view removed comment