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

Create a table named Student with the following details: Insert Sample Data Writ

ID: 3779211 • Letter: C

Question

Create a table named Student with the following details:


Insert Sample Data
Write a program that accepts student id as input and displays student details. If the
student doesn’t exist, display message.
Files to be submitted
• Student.sql
• DisplayStudent.java

Tools Home SY 430 2) Create a table named Student with the following details: Column Data Type Length Condition Values Student ID Int Not mull (primary key Name Varchar 25 Not null Text 4 Not null Major Varchar 10 Level Freshman, Sophomore, Junior, Senior GPA Decimal 2.2 2) Insert Sample Data 3) Write a program that accepts student id as input and displays student details. Tf the student doesn't exist, display message Files to be submitted Student sgl Display Student.java n thing Activa sign in L+ Export put Creates PDF 52 Edit PDF Comment Combine Fill & Sign Send for signature Send & Tin More lools

Explanation / Answer

Please let me know if you need more information:-

=========================================

1.Creating TABLE:-

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

CREATE TABLE Student
(
StudentID int NOT NULL PRIMARY KEY,
Name varchar(25) NOT NULL,
Major TEXT NOT NULL,
Level varchar(10),
GPA DECIMAL(2,2),
CONSTRAINT chk_Level CHECK(Level IN ('FreshMan', 'Sophomore', 'Junior', 'Senior'))
)

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

Java Code to Get the Student Details:-

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

Lets Assume You have ACCESS db:

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

import java.sql.*;
import java.io.*;
import java.lang.*;

class connectiontoaccess
{
public static void main(String[] chinnasrinu)throws ClassNotFoundException,SQLException
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn=null;
conn=DriverManager.getConnection("jdbc:oracle:thin:@135.188.3.81:1521:bppkc","bppadm","RELEASE09");
System.out.println("If this is printed you are connected to DB");
}
}

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

mYSQL:-

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

import java.sql.*;
import java.io.*;
import java.lang.*;
class connectiontomySQL
{
public static void main(String[] chinnasrinu)throws ClassNotFoundException,SQLException
{


Class.forName("com.mysql.jdbc.Driver");
Connection conn=null;
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root","chinnasrinu");
conn=DriverManager.getConnection("jdbc:mysql://localhost/chinnasrinu","chinna","chinnasrinu");
conn=DriverManager.getConnection("jdbc:mysql://localhost/test","root","chinnasrinu");
conn=DriverManager.getConnection("jdbc:mysql://localhost/information_schema","root","chinnasrinu");
System.out.println("welcome to MySQL");
}
}

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

Now to retrieve data from Student Db:-

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

import java.sql.*;
import java.io.*;
import java.lang.*;
class retrive
{
public static void main(String[] chinnasrinu)throws ClassNotFoundException,SQLException
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=null;
conn=DriverManager.getConnection("jdbc:odbc:Database1","chinnasrinu","chinnasrinu");
Statement st=conn.createStatement();
ResultSet rs=st.executeQuery("SELECT * FROM student");
while(rs.next())
{
float nm=rs.getFloat(1);
String m=rs.getString(2);
System.out.println(nm);
System.out.println(m);
}
rs.close();

conn.close();
}
}

=========================

DisplayStudent.java

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

import java.sql.*;
import java.io.*;
import java.lang.*;
class retrive
{
public static void main(String[] chinnasrinu)throws ClassNotFoundException,SQLException
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=null;
conn=DriverManager.getConnection("jdbc:odbc:Database1","chinnasrinu","chinnasrinu");
Statement st=conn.createStatement();
String StudentName = "";//Optional
String sqlQry = "SELECT * FROM Student where studentID='"+StudentName+"'";
ResultSet rs=st.executeQuery(sqlQry);
while(rs.next())
{

int id = rs.getInt("StudentID");
String Name = rs.getString("Name");
java.sql.Blob ablob = rs.getBlob("Major");
String Major = new String(ablob.getBytes(1L, (int) ablob.length()));
String Level = rs.getString("Level");
double GPA = rs.getBigDecimal("GPA").doubleValue();

}
rs.close();

conn.close();
}
}

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

Thanks

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