Let’s say I have swing app and I am using mybatis:
public class MyAppCView extends FrameView {
public SqlSession session;
public StaticMapper mapper;
public Config c = new Config();
public MyAppView(SingleFrameApplication app) {
super(app);
String user="root", pswd="root"
session = MyBatisSqlSessionFactory.getSqlSessionFactory().openSession();
mapper = session.getMapper(StaticMapper.class);
MyBatisSqlSessionFactory looks like this:
public class MyBatisSqlSessionFactory {
public static Map<String,String> propeties = new HashMap<String,String>();
protected static final SqlSessionFactory FACTORY;
static {
try {
Properties props = new Properties();
props.setProperty("username", user);
....
// how can i get variables from swing application into configuration of sqlfactory?
Reader reader = Resources.getResourceAsReader("wsnscc/mybatis/xml/Configuration.xml");
FACTORY = new SqlSessionFactoryBuilder().build(reader,props);
} catch (Exception e){
throw new RuntimeException("Fatal Error. Cause: " + e, e);
}
}
public static SqlSessionFactory getSqlSessionFactory() {
return FACTORY;
}
}
How can I get variables from swing application into configuration of sqlfactory?
Thanks for any advices.
You pass the variables into the SQL factory.
You can do this by changing the class
MyBatisSQLSessionFactoryinto something like this: