Computer Science BS Journal (CST363) : Week 6

 This week I learned quite a bit about JDBC, Connectors, and what it takes to work on some Web Applications. 

*JDBC is the standard Java API for connecting and executing SQL queries with relational databases.

  • Key Concepts:

    • DriverManager / DataSource: Manages DB connections.

    • Connection: Represents a connection session.

    • PreparedStatement: Safely sends parameterized SQL (prevents SQL injection).

    • ResultSet: Retrieves query results.

    Some key takeaways:

    • Use PreparedStatement for safe, efficient, and secure database queries.

    • Always close connections (or use try-with-resources).

    • Avoid hardcoding SQL logic — parameterize everything.

    • Use jdbcTemplate.getDataSource().getConnection() in Spring Boot for quick integration.

*Spring Boot simplifies JDBC usage by handling connection setup and dependency injection through JdbcTemplate.

Key Concepts:

  • @Autowired JdbcTemplate gives access to your DB.

  • Spring Boot reads config from application. Properties (e.g., DB URL, user/pass).

  • DAO (Data Access Object) pattern is often used for cleaner DB logic.

Takeaways:

  • JdbcTemplate abstracts repetitive JDBC code and handles connection pooling.

  • Connection pooling improves performance in web apps.

  • Errors are easier to manage using try-catch around getConnection() or Spring’s exception handling.


What we built(Web Application Lab 18/19):

  • A multi-page Spring Boot web app to manage doctors, patients, prescriptions, pharmacies, and fills.

  • Used forms to:

    • Register and update users.

    • Create and fill prescriptions.

    • Validate and persist data in a MySQL database.

Key Concepts:

  • @Controller classes map URL routes to methods.

  • Model objects pass data from backend to templates.

  • Thymeleaf (via .html templates) renders dynamic views.

  • Forms submit data via @PostMapping to controller methods.

Takeaways:

  • MVC (Model-View-Controller) structure keeps code organized.

  • Views should never trust user input — always validate and cross-check in controller logic.

  • JDBC + Web = full CRUD (Create, Read, Update, Delete) system when properly connected.



Comments

Popular posts from this blog

Computer Science BS Journal: Week 4

Computer Science BS Journal: Week 2

Computer Science BS Journal: Week 5