java

public static void main(String[] args) {
		Connection connection = DBConnection.getConn();
		Statement statement = null;
		ResultSet  resultSet = null;
		int[] rowCount ;
		try {
			statement  =  connection.createStatement();
			String sql1 = "insert into person(name,age,sex) 										values('kobe1',32,'男')";
			String sql2 = "insert into person(name,age,sex) 										values('kobe2',32,'男')";
			String sql3 = "insert into person(name,age,sex) 										values('kobe3',32,'男')";
			statement.addBatch(sql1);
			statement.addBatch(sql2);
			statement.addBatch(sql3);
			rowCount = statement.executeBatch();
			for(int i=0;i<rowCount.length;i++){
				System.out.println("第"+(i+1)+"条语句执行影响的行数为							"+rowCount[i]+"行");
				}
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
			DBConnection.close(connection, statement, resultSet);
		}
	}
 

你可能感兴趣的:(java)