exam的mysql新建数据库_创立数据库表 examstudent

packagecom.hanqi.test;import java.sql.*;import java.util.*;public classLianXi {public static voidmain(String[] args) {

Connection conn= null;try{

Class.forName("oracle.jdbc.driver.OracleDriver");

String strUrl= "jdbc:oracle:thin:@localhost:1521:orcl";

conn= DriverManager.getConnection(strUrl, "test", "5211314");

System.out.println("连接数据库成功!");

System.out.println("输入学生信息");

System.out.println("Type:");

Scanner a1=newScanner(System.in);int b1=a1.nextInt();

System.out.println("IDCard:");

Scanner a2=newScanner(System.in);

String b2=a2.next();

System.out.println("ExamCard:");

Scanner a3=newScanner(System.in);

String b3=a3.next();

System.out.println("StudentName:");

Scanner a4=newScanner(System.in);

String b4=a4.next();

System.out.println("Location:");

Scanner a5=newScanner(System.in);

String b5=a5.next();

System.out.println("Grade:");

Scanner a6=newScanner(System.in);int b6=a6.nextInt();

Statement st=conn.createStatement();

st.executeUpdate("insert into examstudent values( flowid.nextval,"+b1+",'"+b2+"','"+b3+"','"+b4+"','"+b5+"',"+b6+")");

ResultSet rs= st.executeQuery("select * from examstudent");while(rs.next())

{int FlowID= rs.getInt(1);int Type= rs.getInt(2);

String IDCard= rs.getString(3);

String ExamCard= rs.getString(4);

String StudentName= rs.getString(5);

String Location= rs.getString(6);int Grade = rs.getInt(7);

System.out.println("流水号:"+ FlowID + " 四级/六级:"+Type + " 身份证号码:"+IDCard+ " 准考证号码:"+ExamCard+ " 学生姓名:"+StudentName+ " 区域:"+Location+" 成绩:"+Grade);

System.out.println("信息录入成功");

}

rs.close();

st.close();

conn.close();

}catch(Exception e)

{//TODO 自动生成的 catch 块

e.printStackTrace();

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值