hadoop??mysql???????????(1)
???????????? ???????[ 2016/2/3 10:50:14 ] ????????????? MySQL
????????????????hadoop????????????????????????е??????????????hadoop??????????ü???????????????????дС????????????????????ú??????????????????????????????????????????и???????????
?????????????????????????????????hadoop????????mysql?????????е?????????????????д????????????????????????????????????????????????????????hadoop????????????????飬???????HA????????????????η?????????????????????????????鶼????????????????д????????...
????StudentRecord??:
package com.simope.mr.db;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapred.lib.db.DBWritable;
public class StudentRecord implements Writable?? DBWritable{
int id;
String name;
int age;
int departmentID;
@Override
public void readFields(DataInput in) throws IOException {
this.id = in.readInt();
this.name = Text.readString(in);
this.age = in.readInt();
this.departmentID = in.readInt();
}
@Override
public void write(DataOutput out) throws IOException {
out.write(this.id);
Text.writeString(out?? this.name);
out.write(this.age);
out.write(this.departmentID);
}
public void readFields(ResultSet rs) throws SQLException {
this.id = rs.getInt(1);
this.name = rs.getString(2);
this.age = rs.getInt(3);
this.departmentID = rs.getInt(4);
}
public void write(PreparedStatement ps) throws SQLException {
ps.setInt(1?? this.id);
ps.setString(2?? this.name);
ps.setInt(3?? this.age);
ps.setInt(4?? this.departmentID);
}
@Override
public String toString() {
return new String(this.name + " " + this.age + " " + this.departmentID);
}
}
????TeacherRecord??:
package com.simope.mr.db;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapred.lib.db.DBWritable;
public class TeacherRecord implements Writable?? DBWritable{
int id;
String name;
int age;
int departmentID;
@Override
public void readFields(DataInput in) throws IOException {
this.id = in.readInt();
this.name = Text.readString(in);
this.age = in.readInt();
this.departmentID = in.readInt();
}
@Override
public void write(DataOutput out) throws IOException {
out.write(this.id);
Text.writeString(out?? this.name);
out.write(this.age);
out.write(this.departmentID);
}
public void readFields(ResultSet rs) throws SQLException {
this.id = rs.getInt(1);
this.name = rs.getString(2);
this.age = rs.getInt(3);
this.departmentID = rs.getInt(4);
}
public void write(PreparedStatement ps) throws SQLException {
ps.setInt(1?? this.id);
ps.setString(2?? this.name);
ps.setInt(3?? this.age);
ps.setInt(4?? this.departmentID);
}
@Override
public String toString() {
return new String(this.name + " " + this.age + " " + this.departmentID);
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11