I am using JOOQ to access a Rails database, and as you know, Rails has three db schemas, "test", "development" and "production". Let's call these schemas TEST, DEV and PROD for now.
Now I have generated code against DEV with (almost) this setup in library.xml
<jdbc>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://<ip-address>:3306/data_dev</url>
<user>secret</user>
<password>secret</password>
</jdbc>
I connect using code like:
String url = "jdbc:mysql://" +
db_host + "/" +
db_schema + "?" +
"user=" + db_user +
"&password=" + db_pass;
conn = DriverManager.getConnection(url);
dsl = DSL.using(conn, SQLDialect.MYSQL);
Now I want to run the code against PROD, which is identical in structure, but of course have production data.
However, even if I change the connection URL to schema PROD, I still seem to access the DEV? Is the generated code hardcoded to DEV database?
I'm confused how to proceed.
Apparently you can change the mapped DB in runtime.
https://www.jooq.org/doc/latest/manual/sql-building/dsl-context/runtime-schema-mapping/
I completely missed this in the documentation. But thanks for all help anyway...