1 //一般使用方法 2 //优点在于简化sql语句的使用 3 4 5 int deptno = 0; 6 String dname = args[1]; 7 String loc = args[2]; 8 9 10 11 Connection conn = null; 12 13 PreparedStatement stmt = null; 14 15 Class.forName("oracle.jdbc.driver.OracleDriver"); 16 17 conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ELLENIOU", "scott", "tiger"); 18 19 stmt = conn.prepareStatement("insert into dept values (?,?,?)"); 20 21 stmt.setInt(1, deptno); 22 stmt.setString(2, dname); 23 stmt.setString(3, loc); 24 stmt.executeUpdate();