Monday, February 27, 2017

Java and SQL Integration

Nicholas Mulvihill will be presenting code that is used in Java to allow a program to talk to a SQL database.

Here is the Java class API that Oracle put together for SQL.

To setup a Java class to talk to a SQL database you must have credentials for the DBMS and know the driver for the DB. You can generally talk to your DB administrator for this information if you do not know it. For this demonstration, I will use the Department of Computer Science Oracle Database driver, since I know it and how to connect to it.

A general overview of how to connect to the Database:

  • Establish a connection to the Database.
    • DriverManager.getConnection(<driver>,<username>,<password>)
  • Create a Statement and execute a Query.
  • Capture the ResultSet and process returned data
  • Close the connection

In class I will show you the details of the above steps and how to process the ResultSet

6 comments:

  1. Thanks for this presentation. Sorry it didn't work on your laptop, but the points were made. Also like the links you provided.

    ReplyDelete
    Replies
    1. I think it worked out okay even without the laptop. I am glad I posted it on the server just in case!

      Delete
  2. Very good presentation! I really enjoyed how practical it was because Eller students have taken both Java and SQL and this will definitely be helpful down the road at many of our future jobs

    ReplyDelete
    Replies
    1. Thank you Josh, I hope it is useful to some students throughout their career. If anything, at least we all know that it is possible, which could come in handy down the road.

      Delete
  3. I like SQL and Java. I want to learn more about it. Is there any website that teach me more detail? Good presentation and I really enjoy it :)

    Tracy

    ReplyDelete
    Replies
    1. Java is created by oracle, and Oracle has some of the best documentation around. One that I found particularly helpful is: https://docs.oracle.com/javase/tutorial/jdbc/basics/processingsqlstatements.html

      You can get lost on their documentation website, I suggest doing so some day.

      Delete