在eclipse中查看数据库中数据,使用Data Source Explorer -> Schemas - > dbo -> tables -> sample contents
为了检测 SQL 语句的正确性,可以先把它输出,在数据库中执行
PreparedStatement 灵活指定 SQL中的变量
run configuration 输入 Arguments
int deptno = Integer.parseInt(args[0]);
String dname = args[1];
String loc = args[2];
pstmt = conn.prepareStatement("insert into dept2 values (?, ?, ?)");
pstmt.setInt(1, deptno);
pstmt.setString(2, dname);
pstmt.setString(3, loc);
pstmt.executeUpdate();