🚀 Day 2 of My Advanced Java Journey – JDBC Deep Dive Today, I explored deeper into JDBC, focusing on retrieving data, scrollable ResultSets, and metadata. 🔹 Retrieving Data from ResultSet JDBC provides multiple methods to fetch data from each column. We can retrieve data using: Column Index (int) Column Name (String) 👉 Common methods: getInt() getString() getFloat() getDouble() ✔️ Example concept: Using while(res.next()), we can iterate through rows and fetch values like id, name, designation, and salary. 🔹 Scrollable ResultSet (TYPE_SCROLL_SENSITIVE) Unlike normal ResultSets, scrollable ResultSets allow moving the cursor in multiple directions. 👉 Important methods: beforeFirst() afterLast() first() last() next() previous() absolute(int row) 💡 Helps in flexible data navigation. 🔹 ResultSet Metadata Metadata means data about data. Using ResultSetMetaData, we can get: Number of columns → getColumnCount() Column names → getColumnName(int column) Column types → getColumnType(int column) 🔍 What I explored beyond the session Difference between TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, and TYPE_SCROLL_SENSITIVE Importance of CONCUR_READ_ONLY vs CONCUR_UPDATABLE Additional methods like getBoolean(), getDate(), getLong() Why column names are preferred over index (better readability & maintainability) 💡 Mastering ResultSet handling makes JDBC much more powerful for real-world backend applications. 🙌 Special thanks to the amazing trainers at TAP Academy: kshitij kenganavar Sharath R MD SADIQUE Bibek Singh Hemanth Reddy Vamsi yadav Harshit T Ravi Magadum Somanna M G Rohit Ravinder TAP Academy 📌 Learning in public. Growing every day. #Java #AdvancedJava #JDBC #BackendDevelopment #LearningInPublic #100DaysOfCode #VamsiLearns
JDBC Deep Dive: Retrieving Data and Metadata
More Relevant Posts
-
#Post4 In the previous post, we understood how request mapping works using @GetMapping and others. Now the next question is 👇 How does Spring Boot handle data sent from the client? That’s where @RequestBody comes in 🔥 When a client sends JSON data → it needs to be converted into a Java object. Example request (JSON): { "name": "User", "age": 25 } Controller: @PostMapping("/user") public User addUser(@RequestBody User user) { return user; } 👉 Spring automatically converts JSON → Java object This is done using a library called Jackson (internally) 💡 Why is this useful? • No manual parsing needed • Clean and readable code Key takeaway: @RequestBody makes it easy to handle request data in APIs 🚀 In the next post, we will understand @PathVariable and @RequestParam 🔥 #Java #SpringBoot #BackendDevelopment #RESTAPI #LearnInPublic
To view or add a comment, sign in
-
🚀 Day 5 of My Advanced Java Journey – ACID Properties in JDBC Today, I learned how transactions work in databases and why ACID properties are critical for maintaining data integrity. 🔹 What are ACID Properties? ACID ensures reliable and consistent database transactions: Atomicity → Transaction is all or nothing (100% success or rollback) Consistency → Database moves from one valid state to another Isolation → Transactions are independent of each other Durability → Once committed, data remains safe even after failures 🔹 Real-Time Scenario: Money Transfer 💸 Transferring money between two accounts must be handled as a single transaction. 👉 Steps involved: 1️⃣ Load Driver & Establish Connection 2️⃣ Disable AutoCommit con.setAutoCommit(false); 3️⃣ Get sender, receiver, and amount 4️⃣ Debit amount from sender UPDATE acc_details SET balance = balance - ? WHERE name = ? 5️⃣ Credit amount to receiver UPDATE acc_details SET balance = balance + ? WHERE name = ? 6️⃣ Commit or Rollback if(i == 1 && j == 1){ con.commit(); } else { con.rollback(); } 🔹 Key Understanding Both debit and credit must succeed → ensures Atomicity Database remains valid → ensures Consistency Transaction is isolated until completion → ensures Isolation Data persists after commit → ensures Durability 🔍 What I explored beyond the session Importance of setAutoCommit(false) in transaction management Using rollback() to prevent partial updates Handling exceptions properly to avoid data inconsistency Concept of transaction boundaries in real-world applications Basic idea of savepoints for partial rollbacks 💡 ACID properties are the foundation of secure and reliable database systems. 🙌 Special thanks to the amazing trainers at TAP Academy: kshitij kenganavar Sharath R MD SADIQUE Bibek Singh Hemanth Reddy Vamsi yadav Harshit T Ravi Magadum Somanna M G Rohit Ravinder TAP Academy 📌 Learning in public. Building strong fundamentals every day. #Java #AdvancedJava #JDBC #ACID #Database #BackendDevelopment #LearningInPublic #VamsiLearns
To view or add a comment, sign in
-
-
⏳Day 29 – 1 Minute Java Clarity – HashMap Deep Dive + Internal Working How does HashMap actually store data? 🤔 📌 What is HashMap? It's a key-value pair data structure backed by an array of buckets (Node[]) internally. 📌 Internal Working: Map<String, Integer> map = new HashMap<>(); map.put("Alice", 90); // 1. "Alice".hashCode() called // 2. Index calculated (e.g., Index 3) // 3. Stored in Bucket 3 📌 Key Internals at a Glance: Default Capacity: 16 buckets. Load Factor: 0.75 (Resizes when 75% full). Threshold: If a bucket exceeds 8 entries, it transforms from a LinkedList into a Red-Black Tree (Java 8+). ⚠️ The Interview Trap: What happens when two keys have the same hashCode? 👉 This is a collision. They are stored in the same bucket. 👉 Java 7: Uses a LinkedList (Chaining). 👉 Java 8+: Uses a Tree to keep performance at O(log n) instead of O(n). 💡 Real-world Analogy: Think of a Mailroom. hashCode() is the building number (gets you to the right spot fast). equals() is the name on the envelope (finds the exact person). ✅ Quick Summary: ✔ hashCode() decides the bucket. ✔ equals() finds the exact key in case of collisions. ✔ Not thread-safe — use ConcurrentHashMap for multi-threading. 🔹 Next Topic → HashMap vs HashTable vs ConcurrentHashMap Did you know Java 8 uses Red-Black Trees to prevent "Hash Denial of Service" attacks? Drop 🔥 if this was new to you! #Java #HashMap #JavaCollections #CoreJava #BackendDeveloper #1MinuteJavaClarity #100DaysOfCode #DataStructures
To view or add a comment, sign in
-
-
💻 JDBC in Java — Connecting Code with Databases 🚀 Every backend application needs to store, retrieve, and manage data — that’s where JDBC (Java Database Connectivity) comes in 🔥 This visual breaks down the complete JDBC flow with a practical example 👇 🧠 What is JDBC? JDBC is a Java API that allows applications to connect and interact with databases. 👉 It acts as a bridge between Java application ↔ Database 🔄 JDBC Workflow (Step-by-Step): 1️⃣ Load & Register Driver 2️⃣ Establish Connection 3️⃣ Create Statement 4️⃣ Execute Query 5️⃣ Process Result 6️⃣ Close Connection 🔍 Core Components: ✔ DriverManager → Manages database drivers ✔ Connection → Establishes connection ✔ Statement → Executes SQL queries ✔ PreparedStatement → Parameterized queries (secure 🔐) ✔ ResultSet → Holds query results ⚡ Basic Example: Connection con = DriverManager.getConnection(url, user, pass); PreparedStatement ps = con.prepareStatement( "SELECT * FROM students WHERE id = ?" ); ps.setInt(1, 1); ResultSet rs = ps.executeQuery(); while(rs.next()) { System.out.println(rs.getString("name")); } 🚀 Types of JDBC Drivers: Type 1 → JDBC-ODBC Bridge Type 2 → Native API Type 3 → Network Protocol Type 4 → Thin Driver (Most used ✅) 💡 Why use PreparedStatement? ✔ Prevents SQL Injection ✔ Improves performance ✔ Safer for dynamic queries ⚠️ Best Practices: ✔ Always close resources (Connection, Statement, ResultSet) ✔ Use try-with-resources ✔ Handle exceptions properly ✔ Prefer PreparedStatement over Statement 🎯 Key takeaway: JDBC is not just about running queries — it’s the foundation of how Java applications communicate with databases efficiently and securely. #Java #JDBC #Database #BackendDevelopment #Programming #SoftwareEngineering #Coding #100DaysOfCode #Learning
To view or add a comment, sign in
-
-
If you’ve ever wrestled with string-based queries or struggled to keep your database layer type-safe, jOOQ might be the missing piece in your Java stack. N47 Igor Stojanoski #jooq #sql #java 👍 😊 https://lnkd.in/dDYEck3V
To view or add a comment, sign in
-
Spring Data JPA provides built-in query methods based on method naming conventions. Example: find user by name without writing SQL manually. spring-data-jpa. . . . . . . . . . #Java #JavaProgramming #JavaDeveloper #JavaCode #JavaScript #JavaCommunity #JavaTutorial #JavaLearning #JavaDevelopment #JavaLife #JavaLovers #JavaProjects #JavaCoding #JavaTips #JavaFramework #Java8 #JavaEE #JavaForBeginners #JavaGeek #JavaWorld #hackforge [7:53 pm, 26/4/2026] +91 98847 89292: Learn more coding concepts daily with HackForge Academy 🌐 https://www.hackforge.in 📞 9884789292
To view or add a comment, sign in
-
Spring Boot's OSIV default turns your JSON serializer into a hidden query engine I'm building a personal finance platform with Spring Boot 3.5 + Java 21. The first thing I disabled was Open Session in View. Spring Boot ships with spring.jpa.open-in-view=true. That means Hibernate keeps a database connection open through the entire HTTP request - including JSON serialization. When Jackson walks your entity graph to build a response, every uninitialized lazy relationship triggers a database query. Your serializer is now executing SQL. In a load test with HikariCP's default pool of 10 connections and around 150 concurrent requests, this is where things break. Each request holds a connection for the full request lifecycle instead of just the service layer. The pool exhausts, threads queue up, and response times spike. The tricky part is that it works fine in dev when you're the only user. Disabling OSIV forces you to think about what data you actually need. You fetch it explicitly in the service layer with JOIN FETCH or projections, map it to a DTO, and the connection goes back to the pool before serialization even starts. It's more code upfront but the data flow becomes visible instead of hidden behind proxy magic. The second thing I changed was ddl-auto. Hibernate's update mode can generate schema changes automatically, but it can't rename columns, drop unused indexes, or migrate data. It produces a schema that looks right but drifts from what you intended. I use validate with Flyway migrations instead - every schema change is an explicit, versioned SQL file. If the code and the database disagree, the app refuses to start rather than silently diverging. These two defaults share the same problem. They hide complexity that surfaces as production issues. OSIV hides query execution. ddl-auto update hides schema drift. In both cases, making the behavior explicit costs more effort early but removes an entire class of debugging later. #SpringBoot #Java #BuildInPublic #BackendDevelopment
To view or add a comment, sign in
-
What you will learn Acquire proficiency in Java's data structures. Learn to manipulate data using arrays, String class, and Collections Framework. Understand StringBuilder/StringBuffer classes. Use Collections interfaces like ArrayList, LinkedList, HashMap for data management. Learn Spring & Spring Boot, develop Spring applications with dependency, create web apps using Spring MVC, and understand Spring Boot architecture. Master secure RESTful web service creation with Spring Boot. Execute CRUD operations and use Spring Security for web service protection. Skills you will gain Category: Spring Framework Spring Framework Category: Authorization (Computing) Authorization (Computing) Category: Java Programming Java Programming Category: Dependency Analysis Dependency Analysis Category: Object Oriented Programming (OOP) Object Oriented Programming (OOP) Category: Model View Controller Model View Controller Category: Algorithms Algorithms Category: Restful API Restful API Category: Authentications Authentications Category: Java Java Category: Spring Boot Spring Boot Category: Data Structures Data Structures
To view or add a comment, sign in
-
🚀 Day 3 of My Advanced Java Journey — Going Deeper into JDBC! Continuing my journey in Advanced Java, today I explored some powerful JDBC concepts that are widely used in real-world applications. 📚 What I Learned Today: 🔹 CallableStatement Learned how to call stored procedures from Java, making database operations more efficient and reusable. 🔹 ResultSet & Its Types Understood how data is retrieved and processed using ResultSet. Explored different types like: 👉 Forward Only 👉 Scrollable (Insensitive & Sensitive) 🔹 Types of JDBC Drivers Learned about different driver types and how they work: 1️⃣ JDBC-ODBC Bridge 2️⃣ Native API Driver 3️⃣ Network Protocol Driver 4️⃣ Thin Driver (Pure Java) 💡 Key Takeaway: Understanding how JDBC works internally (drivers, result handling, stored procedures) helps in writing efficient, scalable, and production-ready backend code. 🎯 Goal: To master Advanced Java and build strong backend systems with optimized database interactions. 📅 Continuing my Daily Advanced Java Learning Series Stay tuned for Day 4 🔥 #Java #AdvancedJava #JDBC #CallableStatement #ResultSet #JDBCDrivers #LearningInPublic #100DaysOfCode #BackendDevelopment #JavaDeveloper #StudentDeveloper #CareerGrowth
To view or add a comment, sign in
-
-
✨ #Day13 – Hibernate: get() vs load() 🔥 Today I explored an important concept in Hibernate (ORM) – the difference between get() and load() 🚀 🔹 Understanding the Core Difference 🤔 👉 get() ✔ Hits the database immediately ✔ Returns actual object ✔ If data not found → returns null 👉 load() ✔ Does NOT hit DB immediately ✔ Returns a proxy object (lazy loading) ✔ DB hit happens only when data is accessed ✔ If data not found → throws Exception 🔹 Example 🧑💻 Student s1 = session.get(Student.class, 1); // DB hit happens here immediately Student s2 = session.load(Student.class, 1); // No DB hit yet s2.getName(); // Now DB hit happens 🔹 Key Differences 📊 ✔ get() → Safe & direct ✔ load() → Faster & lazy ✔ get() → Use when you're not sure data exists ✔ load() → Use when you're sure data exists 🎯 Quick Trick to Remember 👉 get() = Direct DB hit + null if not found 👉 load() = Lazy + exception if not found 🔥 Takeaway Understanding when Hibernate hits the database helps in writing efficient and optimized backend code 💻 #Java #Hibernate #FullStackDeveloper #BackendDevelopment #LearningJourney #Day13 🚀 Anand Kumar Buddarapu,Saketh Kallepu,Uppugundla Sairam
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development