week 6 sql journal
This week, I learned how to bridge SQL with real-world applications by running database operations directly through Java using Connector/J. It was really interesting to see how concepts like DriverManager, Connection, Statement, and PreparedStatement come together to let a program communicate with a database. I practiced creating connections using the try-with-resources syntax so that connections automatically close, which helps prevent memory leaks or hanging sessions.
I also learned how to handle NULL values, retrieve auto-generated primary keys, and manage transactions using commit() and rollback(). Using PreparedStatements stood out to me because they not only make the code more efficient when executing similar SQL statements multiple times but also protect against SQL injection attacks, which is a huge part of writing secure applications.
In the lab, we applied these ideas by designing a pharmacy database that tracks patients, doctors, prescriptions, and drug data. We created relationships such as a 1-to-many link between doctors and patients and built logic to handle prescription refills, variable pricing per pharmacy, and validation of drug names. This helped me understand how to translate user and business requirements into a professional ER diagram and database design.
Overall, this week tied together both programming and database design skills, showing how SQL isn’t just about queries—it’s the foundation for how applications handle and protect real data.
Comments
Post a Comment