🚀 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
Golla Vamsi’s Post
More Relevant Posts
-
🚀 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
To view or add a comment, sign in
-
-
🚀 Day 2 of My Advanced Java Journey — Diving Deeper into JDBC & Security! Continuing my learning journey in Advanced Java, today I explored some very important real-world concepts related to JDBC and database security. 📚 What I Learned Today: 🔹 Retrieving Data using JDBC Learned how to use SELECT queries and process results using ResultSet. 🔹 SQL Injection (A Major Security Risk) Understood how attackers can manipulate queries through user input and gain unauthorized access. 🔹 PreparedStatement (Solution 💡) Learned how PreparedStatement helps prevent SQL Injection by separating SQL logic from user input. 📌 Key Difference: 👉 Statement → Vulnerable to SQL Injection 👉 PreparedStatement → Secure & Precompiled 💡 Key Takeaway: Writing code is not just about functionality, it's also about security. Using PreparedStatement makes applications more secure, efficient, and reliable. 🎯 Goal: To build secure backend applications with best coding practices. 📅 Continuing my Daily Advanced Java Learning Series Stay tuned for Day 3 🔥 #Java #AdvancedJava #JDBC #SQLInjection #PreparedStatement #LearningInPublic #100DaysOfCode #BackendDevelopment #JavaDeveloper #StudentDeveloper #CareerGrowth
To view or add a comment, sign in
-
-
@Repository in Spring Boot @Repository is used to handle database operations in Spring Boot. It tells Spring: “This class is responsible for interacting with the database.” Key idea: • Fetch data from database • Save data into database • Update and delete records Works closely with: • @Entity → Defines the table • JpaRepository → Provides ready-made methods In simple terms: @Repository → Talks to Database Understanding @Repository helps you manage data easily without writing too much code. #SpringBoot #Java #BackendDevelopment #LearningInPublic
To view or add a comment, sign in
-
🚀 Day 31/45 – Learning JDBC (Database Connectivity) in Java On Day 31 of my Java learning journey, I explored JDBC (Java Database Connectivity), which allows Java applications to interact with databases. This is a crucial concept for building real-world applications that require data storage and retrieval. 📚 What I Learned Today Today I learned: ✔ What JDBC is and how it works ✔ Steps to connect Java with a database ✔ Executing SQL queries using Java ✔ Retrieving data using ResultSet 💻 Practice Work To apply my learning, I implemented: • A program to connect Java with MySQL database • Fetching and displaying records from a table 🎯 Key Takeaway JDBC is essential for building dynamic applications that interact with databases. Understanding database connectivity opens the door to backend development. This is an important step toward becoming a full-stack developer. #Java #Programming #LearningInPublic #CodingJourney #Database #JDBC
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
-
-
Fetching a multi-level hierarchy from a relational database is a classic performance bottleneck. If you do it wrong, you end up with the dreaded N+1 query problem or a Cartesian product that brings your application to its knees. In this session, Java Champion Vlad Mihalcea delves into the most efficient strategies for retrieving complex data structures—specifically for scenarios where you need to store the result set in a cache like Redis. Join us: luma.com/6wrxlqj3
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
-
-
🗄️ Database Optimization is a Game Changer Earlier, I focused only on Java code. But real performance issues often come from DB. Lessons I learned: ✔ Avoid unnecessary queries ✔ Use indexes wisely ✔ Don’t fetch everything 👉 Backend performance = Code + Database Ignoring DB = slow applications. Do you spend time optimizing queries? #SQL #BackendDevelopment #Java
To view or add a comment, sign in
-
One trace. 572,789 spans. 62% of all trace data in a five-minute sample, from a single service. This was a batch processing job. The #OpenTelemetry Java auto-instrumentation agent created a span for every database call inside a loop. The agent does not have a built-in span count cap per trace. It instruments what it finds, and a batch job iterating over hundreds of thousands of records will produce hundreds of thousands of spans. The trace was unusable. No backend renders half a million spans in a waterfall view. The cost was astronomical, and the four largest traces in the sample had no root span metadata, suggesting missing or disconnected parent spans. Most originated from batch or scheduled tasks like `https://lnkd.in/dBWthabm`. This organization runs 3,532 services, all on Java auto-instrumentation v1.33.6. The agent works well for request-response services. It was never designed for uncapped iteration over data. The fix depends on the batch pattern. For jobs that process items independently, use span links instead of parent-child relationships. Each item gets its own trace, linked back to the batch trace. This keeps individual traces small and queryable while preserving the connection to the batch context. For specific instrumentation that generates noise, the agent supports suppression flags. Setting `otel.instrumentation.common.experimental.suppress-messaging-receive-spans=true` eliminates receive spans for messaging consumers. Similar flags exist for JDBC, Redis, and other libraries. Review which instrumentations fire inside your loops and suppress the ones that add volume without insight. Auto-instrumentation assumes your services handle requests. When your workload does not fit that model, you need guardrails. The agent will not set them for you. And about last Friday's quiz: what does `stability: stable` mean for an OpenTelemetry semantic convention attribute? The answer is that it follows semver deprecation rules. A stable attribute is not frozen. It can still be deprecated, but the project must provide a migration path and maintain backward compatibility for a defined period. An `experimental` attribute carries no such guarantee and might be renamed or removed between releases. If you build dashboards or code generation around an experimental attribute, you accept the risk of breakage on upgrade.
To view or add a comment, sign in
-
🚀JDBC - Session 1 | Java Full Stack Learning with Frontlines EduTech (FLM) & Fayaz S. In this session, I learned the fundamentals of JDBC (Java Database Connectivity) – a core concept for integrating Java applications with databases. 🔹 What is JDBC? JDBC stands for Java Database Connectivity. It is an API provided by Java that enables Java applications to interact with relational databases like MySQL, Oracle, etc. 👉 In simple terms: JDBC acts as a bridge between Java applications and databases, allowing us to execute SQL queries and retrieve results. 🔹 Key Concepts Covered ✅ JDBC Drivers JDBC requires a driver to communicate with a database. Examples: MySQL → MySQL Connector/J Oracle → Oracle JDBC Driver These drivers translate Java calls into database-specific commands. 🔹 Steps in JDBC 1️⃣ Load & Register the Driver Load the database-specific driver class Example: Class.forName("com.mysql.cj.jdbc.Driver"); 2️⃣ Establish Connection Connect Java application to database using: URL Username Password Connection con = DriverManager.getConnection(url, username, password); 3️⃣ Create Statement Used to send SQL queries Statement stmt = con.createStatement(); 4️⃣ Prepare SQL Query Write SQL query (SELECT, INSERT, UPDATE, DELETE) 5️⃣ Execute Query Execute using: executeQuery() → for SELECT executeUpdate() → for INSERT/UPDATE/DELETE 6️⃣ Process Result Handle the result using ResultSet ResultSet rs = stmt.executeQuery("SELECT * FROM students"); 7️⃣ Close Resources Always close in reverse order to avoid memory leaks rs.close(); stmt.close(); con.close(); 💡 Key Takeaways JDBC is essential for backend development It enables database interaction using Java Proper resource management is very important ⚠️ #Java #JDBC #JavaFullStack #Database #JavaDeveloper #FrontlinesEduTech
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