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

I need help in creating the following Java file: How do I code it? What else do

ID: 3699897 • Letter: I

Question

I need help in creating the following Java file: How do I code it? What else do I need to add to make it work? The code given below is the beginning of the code.

Codework

Include the following helper code for your 3 files.(note- if some assignment statements in the spec continue to wrap to another line, you may want to adjust your source editor to include the assignment onto one line).

File DbConnect: to allow an object to connect / close a database connection.

DBConnect.java

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.SQLException;

publicclass DBConnect {

// Code database URL

staticfinal String DB_URL = "jdbc:mysql://www.papademas.net/411labs?autoReconnect=true&useSSL=false";

// Database credentials

staticfinal String USER = "db411", PASS = "411";

public Connection connect() throws SQLException {

return DriverManager.getConnection(DB_URL, USER, PASS);

}

}

Remaining helper code below will not include imports for brevity, so please make sure to add them in(Source > Organize Imports)!

Please and thank you.

Explanation / Answer

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.SQLException;

public class DBConnect {

// Code database URL

static final String DB_URL = "jdbc:mysql://www.papademas.net/411labs?autoReconnect=true&useSSL=false";

// Database credentials

static final String USER = "db411", PASS = "411";

public Connection connect() throws SQLException, ClassNotFoundException {

//Invokes Driver class

Class.forName("com.mysql.jdbc.Driver");  

return DriverManager.getConnection(DB_URL, USER, PASS);

}

}

/*

To connect to mysql database you should hava mysql-connector.jar in class path. If you already hava the jar then the above code will work fine. If you don't have the jar then download mysql-connector.jar and place the jar file in C:Program FilesJavajre****libext folder.

*/

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