Can I change the database name temporarily while running Platform?

I need some guidance, how could I change the database name on login, and close the session and open it again?

What I have been trying is

in authenticate: session.close();

then

      AnnotationConfiguration conf = new AnnotationConfiguration();
      // <!-- Database connection settings -->
      conf.setProperty("hibernate.connection.url", "jdbc\\:mysql\\://localhost\\:3306/kenntman?autoReconnect\\=true&sessionVariables\\=storage_engine\\=InnoDB&useUnicode\\=true&characterEncoding\\=UTF-8");
      conf.setProperty("hibernate.connection.username", "openmrs-user");
      conf.setProperty("hibernate.connection.password", "openmrs2");
      conf.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
      conf.setProperty("hibernate.cache.provider_class", "org.hibernate.cache.EhCacheProvider");
      //conf.configure();
      
      SessionFactory SESSION_FACTORY = conf.configure().buildSessionFactory();
      
      
      return SESSION_FACTORY;

Which would be the easiest way?

Thanks in advance

It’s not clear to me why you’re doing this, what is the specific issue you’re trying to solve? Why would you want to change the DB name at runtime when you can set it before starting the application?

Can you give more details of what exactly you are trying to do? And is it something you’re doing from a module running alongside the web application or it is a custom application running on top of the OpenMRS API?

What I am trying to do is a kind of multi-tenancy since to have several instances would be too expensive, so I am thinking to change the conection string based on the url for example http://hospital1.website.com/openmrs so on login I would change the connection to database hospital1 if login hospital2 I would change the connection string to hospital2 and so on.

Does it clarify a lit of bit more.

Yes, it clarifies what you’re trying to do.

I don’t think this is possible to do with OpenMRS, and I recommend trying some other approach…

··· On Mon, Mar 14, 2016 at 4:17 PM, Mau Jimenez wrote:

mjeduar https://talk.openmrs.org/users/mjeduar Mau Jimenez https://talk.openmrs.org/users/mjeduar March 14

What I am trying to do is a kind of multi-tenancy since to have several instances would be too expensive, so I am thinking to change the conection string based on the url for example http://hospital1.website.com/openmrs so on login I would change the connection to database hospital1 if login hospital2 I would change the connection string to hospital2 and so on.

Does it clarify a lit of bit more.

Visit Topic https://talk.openmrs.org/t/change-database-name-on-runtime/5266/4 or reply to this email to respond

In Reply To wyclif https://talk.openmrs.org/users/wyclif Wyclif Luyima https://talk.openmrs.org/users/wyclif /dev/5 March 14 Can you give more details of what exactly you are trying to do? And is it something you’re doing from a module running alongside the web application or it is a custom application running on top of the OpenMRS API?

Visit Topic https://talk.openmrs.org/t/change-database-name-on-runtime/5266/4 or reply to this email to respond

To stop receiving notifications for this particular topic, click here https://talk.openmrs.org/t/change-database-name-on-runtime/5266/unsubscribe. To unsubscribe from these emails, change your user preferences https://talk.openmrs.org/my/preferences

or, click here <reply@talk.openmrs.org?subject=unsubscribe> to unsubscribe via email.

I think is possible, you know everything is possible, I just need an idea how to make it

Hahahaha. I love the everything is possible spirit! :smile:

@mjeduar to add to what Darius is saying is that the way OpenMRS works it is not supported meaning it is not possible