Package Com.eeepay.lzj.db;import Java.sql.connection;import Java.sql.date;import java.sql.drivermanager;import Java.sql.preparedstatement;import Java.sql.resultset;import Java.sql.sqlexception;import com.jcraft.jsch.JSch; Import Com.jcraft.jsch.session;public class Changedb {public static int lport = 33102;//Local port (random fetch) public static Strin G Rhost = "172.***.***.***";//remote MySQL server public static int rport = 3306;//remote MySQL service port public static void Go () {String user = "* * *";//ssh connection user name string password = "******";//ssh connection Password string host = "120.132.***.***";//ssh server int port = * * * * *;//ssh Access Port try {Jsch Jsch = new Jsch (); Session session = Jsch.getsession (user, host, port), Session.setpassword (password); Session.setconfig (" Stricthostkeychecking "," no "); Session.connect (); System.out.println (Session.getserverversion ());//Here Print SSH server version information int assinged_port = SESSION.SETPORTFORWARDINGL ( Lport, Rhost, Rport); System.out.println ("localhost:" + assinged_port + "+" + rhost + ":" + Rport);} catch (ExCeption e) {e.printstacktrace ();}} public static void Main (string[] args) {string Mobileno;//mobile_username string Accountname;//account_name string A Ccountno;//account_no string Cnaps;//cnaps_no string bankname;//bank_name string Realname;//lawyer int sta Tus;//open_status string Password;//mobile_password string idcard;//id_card_no int Realnameauth;//real_flag Da Te Createtime;go (); try {///1, Load Driver Class.forName ("Com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) {//TODO auto-generated catch block E.printstacktrace (); }//2, create connection Connection conn = null; Connection conn2 = null; try {conn = drivermanager.getconnection ("Jdbc:mysql://localhost:33102/posp", "* * * *", "* * *"); CONN2 = Drivermanager.getconnection ("Jdbc:mysql://115.29.***.***:3306/bag", "* * * *", "* * * * *"); } catch (SQLException e) {System.out.println ("Database Not Connected"); E.printstacktrace (); } PreparedStatement pstmt = null; PreparedStatement pstmt2 = null; PreparedStatement pstmt22 = null; PreparedStatement pstmt3 = null; try {String sql = "Select Mobile_username,account_name,account_no,cnaps_no,bank_name,lawyer,open_status,mobile _password,id_card_no,real_flag,create_time from Pos_merchant "; String sql = "SELECT * from Settle_account where id=1"; String sql2 = "INSERT INTO Bag_login (mobile_no,status,real_name,create_time,password,pay_password,idcard,real_name_ Auth) VALUES (?,?,?,?,?,?,?,?) "; String sql22 = "SELECT * from Bag_login where mobile_no=?"; String sql3 = "INSERT into Settle_account (mobile_no,account_name,account_no,cnaps,bank_name,create_time) VALUES (?,?, ?,?,?,?)"; pstmt = conn.preparestatement (sql); PSTMT2 = Conn2.preparestatement (SQL2); pstmt22 = Conn2.preparestatement (sql22); PSTMT3 = Conn2.preparesTatement (SQL3); ResultSet rs = Pstmt.executequery (); int i=1; while (Rs.next ()) {System.out.println (i++); Createtime = Rs.getdate ("Create_time"); Mobileno = rs.getstring ("Mobile_username"); AccountName = rs.getstring ("account_name"); Accountno = rs.getstring ("Account_no"); Cnaps = rs.getstring ("Cnaps_no"); Bankname = rs.getstring ("Bank_name"); Realname = rs.getstring ("lawyer"); Status = Rs.getint ("Open_status"); Password = rs.getstring ("Mobile_password"); Idcard = rs.getstring ("Id_card_no"); Realnameauth = Rs.getint ("Real_flag"); Pstmt3.setstring (1, Mobileno); Pstmt3.setstring (2, AccountName); Pstmt3.setstring (3, Accountno); Pstmt3.setstring (4, cnaps); Pstmt3.setstring (5, bankname); Pstmt3.setdate (6, createtime); Pstmt3.execute (); Pstmt22.setstring (1, Mobileno); if (!pstmt22.execute ()) {pstmt2.setstring (1, Mobileno); Pstmt2.setint (2, status); Pstmt2.setstring (3, realname); Pstmt2.setdate (4, createtime); Pstmt2.setstring (5, password); Pstmt2.setstring (6, password); Pstmt2.setstring (7, Idcard); Pstmt2.setint (8, Realnameauth); Pstmt2.execute (); }}} catch (SQLException e) {//TODO auto-generated catch block E.printstacktrace (); } finally{try {pstmt.close (); Conn.close (); Pstmt2.close (); Conn2.close (); Pstmt3.close (); } catch (SQLException e) {//TODO auto-generated catch block E.printstacktrace (); } }}}