Search code examples
javaibatismybatis

Setting Schema for MyBatis (iBatis)


I am calling SqlSession.openSession(Connection) in MyBatis. The Connection is to a MySQL database and does not have a schema specified in the URL (e.g. jdbc:mysql://localhost). I'd like to set a "default schema" in MyBatis that will be used to execute mapped queries against, but I can't find out how. Does anyone know?


Solution

  • If your mapped queries generated with MyBatis Generator, before generation you could set schema and it prepends its name to the queries. Without writing schema name, MyBatis couldnt set default schema.