import java.sql.*;
public class Sb {
public static void main(String[] args) {
Connection con;
Statement sql, sql2;
ResultSet rs, rs2;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e) {
System.out.println("寻找不到该类" + e.getMessage());
}
try {
con = DriverManager.getConnection("JDBC:ODBC:300gui","","");
sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
sql2 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs = sql.executeQuery("SELECT * FROM glass ORDER BY PersonNumber");
rs2 = sql2.executeQuery("SELECT * FROM main ORDER BY PersonNumber");
rs.last();
int a = rs.getRow();
rs.first();
rs2.last();
int b = rs2.getRow();
rs2.first();
for(int i=1;i<=a;i++) {
rs.absolute(i);
String p1 = rs.getString(3);
String i1 = rs.getString(4);
int w1 = rs.getInt(8);
for(int j=1;j<=b;j++) {
rs2.absolute(j);
String p2 = rs2.getString(3);
String i2 = rs2.getString(4);
int w2 = rs2.getInt(8);
if(p2.equals(p1) && i2.equals(i1)) {
rs2.updateInt("Wages",w1);
rs2.updateRow();
System.out.println(w1);
break;
}
}
}
rs2.first();
for(int k=1;k<=b;k++) {
rs2.absolute(k);
String x = rs2.getString(3);
String y = rs2.getString(4);
int z = rs2.getInt(8);
System.out.print("个人编号; " + x + " ");
System.out.print("身份证号; " + y + " ");
System.out.println("工资; " + z + " ");
}
}
catch(SQLException e) {
System.out.println("数据库操作错误!" + e.getMessage());
}
}
}