Dynamic DB configuration

#1

Is there any way to dynamically specify the URL/id/pw for a DB-VA generated project. It seems that these are hardcoded in the database.cfg.xml and [project].cfg.xml. Is there anyway to specify these dynamically from within my main application.
Thanks

Susan Frye

0 Likes

How to write test with orm.jar
#2

Dear Susan,

Sorry for my late reply. Yes, you can dynamically specify in code the URL, user name, password and other parameters related to connection. Here is the code sample:

JDBCConnectionSetting connectionSetting = new JDBCConnectionSetting();
connectionSetting.setConnectionURL("jdbc:mysql:///test");
connectionSetting.setDialect("org.hibernate.dialect.MySQLDialect");
connectionSetting.setDriverClass("com.mysql.jdbc.Driver");
connectionSetting.setUserName("root");
connectionSetting.setPassword("pwd");
UntitledPersistentManager.setJDBCConnectionSetting(connectionSetting);

Note that you should invoke the above methods BEFORE calling PersistentManager.instance().

If there are any questions, please let me know.

Best Regards,
Jick

0 Likes

#3

[quote=Jick]Dear Susan,

Sorry for my late reply. Yes, you can dynamically specify in code the URL, user name, password and other parameters related to connection. Here is the code sample:

JDBCConnectionSetting connectionSetting = new JDBCConnectionSetting();
connectionSetting.setConnectionURL("jdbc:mysql:///test");
connectionSetting.setDialect("org.hibernate.dialect.MySQLDialect");
connectionSetting.setDriverClass("com.mysql.jdbc.Driver");
connectionSetting.setUserName("root");
connectionSetting.setPassword("pwd");
UntitledPersistentManager.setJDBCConnectionSetting(connectionSetting);

Note that you should invoke the above methods BEFORE calling PersistentManager.instance().

If there are any questions, please let me know.

Best Regards,
Jick

[/quote]

How to do this with C#?

0 Likes

#4

Hi,

I am sorry, dynamic DB configuration is available in Java ORM only. I will pass your request to our engineers to follow up.

Best Regards,
Jick

0 Likes

#5

[quote=Jick]Hi,

I am sorry, dynamic DB configuration is available in Java ORM only. I will pass your request to our engineers to follow up.

Best Regards,
Jick
[/quote]

Normally, how long will it take for this feature to release? (Because I am urgent in using it.)

0 Likes

#6

And, can the connection string be set by .getCfg.setProperty?

0 Likes

#7

Dear Susan,

The ability of dynamic db configuration for C# ORM is added in the latest release. Please update your tool with the update program, and re-generate the ORM. The following article shows you how to perform update:
http://resource.visual-paradigm.com/tips_and_tricks/general/keeping_your_tool_up-to-date_by_vp_suite_update.html

Here is method calls related to DB configuration in C# ORM:

Orm.Cfg.DotNetConnectionSetting setting = new Orm.Cfg.DotNetConnectionSetting();
setting.ConnectionString = "Server=localhost;Database=test;User ID=root";
setting.Dialect = "NHibernate.Dialect.MySQLDialect";
setting.DriverClass = "NHibernate.Driver.MySqlDataDriver";
UntitledPersistentManager.SetConnectionSetting(setting);

If there are any questions, please feel free to let me know.

Best Regards,
Jick

0 Likes