代码拉取完成,页面将自动刷新
import java.sql.*;
public class Example11_4 {
public static void main(String args[]) {
Connection con;
Statement sql;
ResultSet rs;
con = GetDBConnection.connectDB("students","root","sunxiaoxuan001");
if(con == null ) return;
String jiLu="('R11','将三','2000-10-23',1.66),"+
"('R10','李武','1989-10-23',1.76)"; //2条记录
String sqlStr ="insert into mess values"+jiLu;
String sql1 = "delete from mess where number = 'R1001'";
try {
sql=con.createStatement();
int ok = sql.executeUpdate(sqlStr);
rs = sql.executeQuery("select * from mess");
while(rs.next()) {
String number=rs.getString(1);
String name=rs.getString(2);
Date date=rs.getDate(3);
float height=rs.getFloat(4);
System.out.printf("%s\t",number);
System.out.printf("%s\t",name);
System.out.printf("%s\t",date);
System.out.printf("%.2f\n",height);
}
con.close();
}
catch(SQLException e) {
System.out.println("记录中number值不能重复"+e);
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。