Computer Science, asked by HarshTomar8358, 3 months ago

develop a program to display the name and roll no of students from student table having percentage >70 in java

Answers

Answered by eishalkhan2020
4

Answer:

the answer is

Explanation:

You can use excel sheet and learn from youtube how to do work in it and you can have a print out of it aswell

Answered by qwstoke
0

Here is an example of a Java program that can display the name and roll number of students from a student table who have a percentage greater than 70:

import java.sql.*;

public class Student {

   public static void main(String[] args) {

       try {

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

           Connection con = DriverManager.getConnection(

               "jdbc:mysql://localhost:3306/studentdb", "username", "password");

           Statement stmt = con.createStatement();

           ResultSet rs = stmt.executeQuery("SELECT name, roll_no FROM student WHERE percentage > 70");

           while (rs.next()) {

               System.out.println("Name: " + rs.getString(1) + ", Roll Number: " + rs.getString(2));

           }

           con.close();

       } catch (Exception e) {

           System.out.println(e);

       }

   }

}

  • This program uses the JDBC (Java Database Connectivity) API to connect to a MySQL database named "studentdb" on the localhost. It then creates a statement and executes a query that selects the name and roll number of all students who have a percentage greater than 70. The results of the query are then displayed on the console.
  • Please note that you will need to replace the username and password with the actual username and password for your MySQL database, and you need to import the JDBC driver for your database in your classpath.

#SPJ3

Similar questions