Class.forName("oracle.jdbc.driver.OracleDriver"); String url = "jdbc:oracle:thin:@你的主机ip :1521:orcl";// 设置连接字符串 String username = "你的用户名"; String password = "你的密码"; Connection con=java.sql.DriverManager.getConnection(url,user,password); Statement stmt = con.createStatement(); StringBuffer sql = new StringBuffer("insert into user values (" + list.get(1).getId()+", "+list.get(1).getUserName()+", "+list.get(1).getPassword()+")"); for(int i = 2; i < list.size(); i++){ sql.append(", ("+ list.get(i).getId()+", "+list.get(i).getUserName()+", "+list.get(i).getPassword()+")");// } sql.append(";"); ResultSet rs = stmt.executeQuery(sql); rs.close(); stmt.close(); con.close();
时间: 2024-10-05 16:23:31