pv_data为table类型的数据
//这里创还能sink进行与mysql的连接 class mysqlsink extends RichSinkFunction<Row>{ Connection cn=null; PreparedStatement ps =null; @Override public void open(Configuration parameters) throws Exception { Class.forName("com.mysql.jdbc.Driver"); cn = DriverManager.getConnection("jdbc:mysql://hadoop102:3306/数据库", "user", "password"); ps = cn.prepareStatement("insert into ta values (?,?)"); //这里写入sql ?为占位符方便下面的数据写入 } @Override public void close() throws Exception { cn.close(); ps.close(); } @Override public void invoke(Row value, Context context) throws Exception { ps.setObject(1,value.getFieldAs(0)); ps.setObject(2,value.getFieldAs(1)); //这里根据数据进行修改 ps.executeUpdate(); } }