1 // 1.加载驱动程序 2 Class.forName("oracle.jdbc.driver.OracleDriver"); 3 // 2.获取数据库连接 4 Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "j0408", "1"); 5 // 3.构建SQL语句 6 String sql = "insert into t_user(userid,username,password)values(seq_t_user.nextval,'abc','123456')"; 7 // 4.执行SQL语句 8 Statement sts = conn.createStatement(); 9 // 返回的结果是影响的行数 10 int count = sts.executeUpdate(sql); 11 System.out.println("影响的行数:"+count); 12 // 5.关闭资源 13 sts.close(); 14 conn.close();