Question: Write Java applications to do the following: ? Create table ? Insert data ? Select statements You may have to create multiple programs. Make sure

Write Java applications to do the following: ? Create table ? Insert data ? Select statements You may have to create multiple programs. Make sure you upload screen shots of the working applications. You can use the class program templates but your program has to create different tables and insert at least 5-7 records and show result sets using select statements.

Class Program:

package dataextract;

import java.sql.*;

public class DataExtract {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

try

{

String driver = "com.mysql.jdbc.Driver";

String url = "jdbc:mysql://localhost:3307/newclass";

String user = "root";

String passwd = "";

Class.forName(driver);

Connection conn = DriverManager.getConnection(url, user, passwd);

String query = "Select * from classtudent";

Statement st = conn.createStatement();

ResultSet rs = st.executeQuery(query);

while (rs.next())

{

int classID = rs.getInt("classID");

int classNumber = rs.getInt("classNumber");

String classPrefix = rs.getString("classPrefix");

System.out.format("%s, %s, %s ", classID, classNumber, classPrefix);

}

st.close();

}

catch (Exception e)

{

System.err.println("Error");

System.err.println(e.getMessage());

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!