Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. Decipher \"the code\" snippet lines As done in class, review the code below,

ID: 3600803 • Letter: 2

Question

2. Decipher "the code" snippet lines As done in class, review the code below, and based on what we've learned about Java: (20 points) standard naming conventions statement "types" . . syntax describe what each line of code is doing - in plain English, but use the appropriate terms. For example: "an instance of SomeClass is being created (or instantiated)y would be an accurate description of this one line of code: SomeClass theObject = new SomeClass(); "jdbc : mysql://localhost/world?usersu s r&passwordspw123;", tring Connection connection = Drive rManager.getConnection (url); // (1) statement statement connection.createstatement( url =

Explanation / Answer

String url = "jdbc:mysql://localhost/world?user=usr&password=pw123";

Explanation : An String object with the name "url" is created, which has the value "jdbc:mysql://localhost/world?user=usr&password=pw123".

---------------------------------------------------------------------------------------------------------------------------------------------------------

Connection connection = DriverManager.getConnection(url);

Explanation : DriverManager is the basic service for managing a set of JDBC drivers.As part of its initialization, the DriverManager class will attempt to load the driver classes referenced in the "jdbc.drivers" system property. This allows a user to customize the JDBC Drivers used by their applications.

The DriverManager methods getConnection and getDrivers have been enhanced to support the Java Standard Edition Service Provider mechanism. JDBC 4.0 Drivers must include the file META-INF/services/java.sql.Driver. This file contains the name of the JDBC drivers implementation of java.sql.Driver.

A connection (session) with a specific database. SQL statements are executed and results are returned within the context of a connection.

Here, with the help of the static Method DriverManager.getConnection), the Object of a Connection Class connection is given a reference to a specific JDBC Connection, which in this case is a MySQL JDBC Connection, using the username = usr and password = pw123.

____________________________________________________________________________________________

Statement statement = connection.createStatement();

Explanation : Statement Class is used for for executing a static SQL statement and returning the results it produces.

In the above code, an Object statement of the Class Stament is given a reference to a Statement Object, which we get from calling the method connection.createStatement()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote