This code prompts the user to input a last name, and then uses the JDBC (Java Database Connectivity) library to search a database for students with that last name. It then prints out a table of the students' information, including their student ID, name, class, age, and gender.

System.out.println('请输入姓氏:');
String lastName = sc.next();
List list3 = JDBC.findStudentByLastName(lastName);
System.out.println('学号	姓名	班级	年龄	性别');
for (Student s : list3) {
System.out.println(s.getSno() + '	' + s.getSname() + '	' + s.GetClass() + '	' + s.getAge() + '	' + s.getSex());
}

This code demonstrates a basic example of using JDBC to query a database and display the results in a formatted table.

Java JDBC 查询学生信息 - 按姓氏检索

原文地址: https://www.cveoy.top/t/topic/nH3D 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录