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

This is for Java. Please do not just post code already found on this site, I wou

ID: 3855216 • Letter: T

Question

This is for Java.

Please do not just post code already found on this site, I would like a different answer.

Please test code prior to publishing

The objective of this assignment is to allow you to work with JDBC via an ODBC-connected Access database.

Your first task for this assignment is to locate and set up the "exampleMDB.mdb" file in the supplemental chapters section of the CD-rom that came with your Liang text. Copy this file to your hard drive. Next, create an ODBC connection to this database called "assignment8".

Next, create a simple Java program that connects to this database using JDBC. Your program should then query this database's "student" table and display a list of all the students' names in alphabetic order (based upon last name).

If you implement your program correctly, this is the output you should see:

Rick R. Carter

Frank E. Jones

Joy P. Kennedy

Toni R. Peterson

Josh R. Smith

Jean K. Smith

George K. Smith

Jacob R. Smith

John K. Stevenson

Patrick R. Stoneman

Josh R. Woo

Explanation / Answer

I dont have the mdb file to show screenshot but below code helps you , make sure you replace the location of mdb file with the one in you hard drive . Upvote if satisfied else comment :

package chegg.work;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.Statement;

public class DatabaseConnect {

public static void main(String[] args) throws Exception {

Connection assignment8 = getConnection();

Statement st = assignment8.createStatement();

st = assignment8.createStatement();

ResultSet rs = st.executeQuery("SELECT studentName FROM student ORDER BY studentName ASC");

int i = 0;

while (rs.next()) {

System.out.println(rs.getString(i));

i++;

}

st.close();

assignment8.close();

}

private static Connection getConnection() throws Exception {

String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\__tmp\exampleMDB.mdb;";

String driver = "sun.jdbc.odbc.JdbcOdbcDriver";

String username = "";

String password = "";

Class.forName(driver);

return DriverManager.getConnection(database, username, password);

}

}

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