day33-1用java的jdbc添加数据库中表的内容

package zuoye;

import java.sql.Connection;
import java.sql.Statement;

public class text {
public static void main(String[] args) {
Connection conn =null;
Statement stat =null;
try {
conn = zuoye.getConnection();
String s = "insert into emp values(1016,'孙悟空',4,1004,'2018-12-17','8000.00',NULL,20)," +
"(1017,'孙悟空1',4,1004,'2018-12-17','8000.00',NULL,20)," +
"(1018,'孙悟空2',4,1004,'2018-12-17','8000.00',NULL,20)," +
"(1019,'孙悟空3',4,1004,'2018-12-17','8000.00',NULL,20)," +
"(1020,'孙悟空4',4,1004,'2018-12-17','8000.00',NULL,20)";
stat = conn.createStatement();
int i = stat.executeUpdate(s);
System.out.println(i);
if(i>0){
System.out.println("添加成功");
}else{
System.out.println("添加失败");
}
} catch (Exception e) {
e.printStackTrace();
}finally {
zuoye.a(conn,stat);
}
}
}
原文地址:https://www.cnblogs.com/hfew/p/10640368.html