Week 6 - JDBC

Week 6 -

Wow, it's nearly the end of this class already with only one and half weeks left. The time went by so quickly. This week was refreshing as we got to engage in Java Programming while utilizing an API that allows Java programs to access and manipulate data stored on our relational database in a MYSQL server. Materials this week sort of answered my question from the previous weeks on how we utilize SQL in certain applications developed in other languages. Some information that I gathered was about the different programming languages such as imperative languages where it involves control flow statements to execute in a certain order; as some languages are procedural where their procedures involve functions like C or COBOL while others involve object oriented classes like Java, Python and C++. Then there are declarative languages which do not contain control flow statements but rather there are statements that declare the results it desires using logical expressions; notable examples are SQL and HTML.

The most important concept this week was learning about how embedded SQL works, which involves how to write an SQL statement within a host programming language like C or C++. From my own words the way it works is that the SQL statements are embedded with special syntax such as EXEC SQL and END-EXEC in C language. Then the precompiler scans the SQL statements translating them into function calls that interact with the database, the SQL statements and host language can utilize shared variables to share data by using a shared declare section, then at runtime the host language program is connected to a database, sends the SQL statements and processes the results. There you can utilize a cursor to retrieve and process the query results one row at a time.

Lastly, I'll touch up on the information I learned about database API and JDBC. The API allows for specific interactions between the host language application for example Java app to a database. One notable API we have been using is JDBC. The API allows us to manage the connection to a database using the address and login information which the connection would allow for queries to be executed. In addition I've learned ways to prepare queries, execute queries with statement interfaces for example executeQuery() for SELECT queries and executeUpdate() for INSERT, UPDATE and DELETE queries, fetch values using the ResultSet interface, and utilizing query parameters to avoid SQL injection attack with PreparedStatement extended interface.

Overall this week was quite fun and I am definitely absorbing the information for future projects. The last thing to do is one more group project and the final. I'll try my best to not get lazy and keep up with the work for the rest of the course. Here's to a new week!

Comments