How to migrate the database from Filemaker to Mysql?

前端 未结 3 1331
野性不改
野性不改 2021-01-12 20:54

I am rebuilding an ERP system based on Symfony1.4 and MySQL 5.1. The challenge is that previous system was built on Filemaker Pro and I have to migrate all previous data to

3条回答
  •  醉酒成梦
    2021-01-12 21:26

    I'm doing this in Java at the moment using JDBC. You need to import the JDBC driver and MySQL into your library. I'm currently looking in my other posts for the best practices to processing this large amount of data.

    You might have to make the tables yourself in MySQL, and I might go as far as to recommend it, because FMPro typically has a strange setup, that you might not want to copy exactly (I noticed on the most recent one text fields have to be set to a length too or things just go haywire..). An easy afternoons work in MySQL Developer (or whatever they call it now) drawing some nice diagrams?

    Here's some cheats:

    public static String dbaseURL = "jdbc:filemaker://machineIP:2399/database";
    
    public static void FMProConnect() {
    
    // Load the JDBC to ODBC driver
    try {
    
        Class.forName("com.filemaker.jdbc.Driver");
    
    } catch(java.lang.ClassNotFoundException e) {
            System.err.print("ClassNotFoundException: ");
            System.err.println(e.getMessage());
    }
    }
    public static void copyTable(){
    FMProConnection.FMProConnect();
    Connection dbConnection = null;
    Statement query = null;
    PreparedStatement stmt = null;
        try {
          // Create a database connection
      dbConnection =
        DriverManager.getConnection(dbaseURL, "fmprouser", "fmpropassword");
      // Create a statement and execute the SQL query
      query = dbConnection.createStatement();
    }
    catch (SQLException e) {
      System.out.println("Error connecting to dbase.");
      e.printStackTrace();
      //System.exit(1);
    }
    
    ResultSet results = null;
    try {
    
      results =
        query.executeQuery("SELECT * from table");
    
      // Iterate through the results and print them to standard output
         Connection con = DriverManager.getConnection("jdbc:mysql://mysqlserver.com/database","username","password");
    
      while (results.next()) {
        String fname = results.getString("field");
        String lname = results.getString("field1");
     // System.out.println("Found user \"" + fname + " " + lname + "\"");
      stmt = con.prepareStatement("INSERT ignore INTO table (field, field1 values (?, ?)");
      stmt.setString(1, fname);
      stmt.setString(2, lname);
      stmt.executeUpdate();
    
      }
      System.out.println("Completed Customers");
    }
    catch (SQLException e) {
      System.out.println("Error retrieving data from database.");
       e.printStackTrace();
      //System.exit(1);
    }
    
    
    }
    

提交回复
热议问题