SyncMasterDoubaoModel.java 1.7 KB

123456789101112131415161718192021222324252627282930313233
  1. import java.sql.*;
  2. /** Sync master ylrz_saas doubao row to match working tenant endpoint/id. */
  3. public class SyncMasterDoubaoModel {
  4. public static void main(String[] a) throws Exception {
  5. Class.forName("com.mysql.cj.jdbc.Driver");
  6. String tenantJdbc = "jdbc:mysql://cq-cdb-8fjmemkb.sql.tencentcdb.com:27220/fs_tenant_cs1"
  7. + "?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8";
  8. String masterJdbc = "jdbc:mysql://cq-cdb-8fjmemkb.sql.tencentcdb.com:27220/ylrz_saas"
  9. + "?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8";
  10. String id = null, key = null, ep = null;
  11. try (Connection tc = DriverManager.getConnection(tenantJdbc, "root", "Ylrz_1q2w3e4r5t6y");
  12. Statement ts = tc.createStatement();
  13. ResultSet rs = ts.executeQuery(
  14. "SELECT model_identifier, api_key, api_endpoint FROM admin_ai_model WHERE provider_code='doubao' LIMIT 1")) {
  15. if (rs.next()) {
  16. id = rs.getString(1);
  17. key = rs.getString(2);
  18. ep = rs.getString(3);
  19. }
  20. }
  21. if (id == null) {
  22. System.out.println("tenant doubao not found");
  23. return;
  24. }
  25. try (Connection mc = DriverManager.getConnection(masterJdbc, "root", "Ylrz_1q2w3e4r5t6y");
  26. Statement ms = mc.createStatement()) {
  27. ms.executeUpdate("UPDATE admin_ai_model SET model_identifier='" + id + "', api_key='" + key
  28. + "', api_endpoint='" + ep + "', update_time=NOW() WHERE provider_code='doubao'");
  29. System.out.println("master doubao synced id=" + id + " ep=" + ep);
  30. }
  31. }
  32. }