Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create slave databases in windows environment #229

Open
faysalmehmood opened this issue Oct 1, 2021 · 4 comments
Open

Unable to create slave databases in windows environment #229

faysalmehmood opened this issue Oct 1, 2021 · 4 comments
Assignees

Comments

@faysalmehmood
Copy link

When you add multiple databases (slave), there is a convention of using colon ":" in database configuration file names. But while working on windows operating system, it seems impossible to create a file name having colon in its name.
For example:
In cfg directory, db.properties is fine. But following file names are problematic as these cannot be created.
slave1:db.properties
slave2:db.properties

If there is a workaround, please assist. And if it's really an issue, would appreciate to provide its support.

@ar
Copy link
Member

ar commented Oct 1, 2021

Very good point. When I decided to use that colon, I thought about DOS and hard drives, but thought Windows would have overcome that limitation already. We'll figure out how to solve this, probably using just another dot.

@ar ar self-assigned this Oct 1, 2021
@faysalmehmood
Copy link
Author

That will definitely help. Thanks!

@ar
Copy link
Member

ar commented Oct 18, 2021

I read that percent encoding can be used in Windows to represent a colon.

On Windows systems, files and directory names cannot be created with a colon (:). But if a file or directory name is created with a colon on a Linux or Mac operating system, then moved to a Windows system, percent encoding is used to include the colon in the name in the index.

Can you give that workaround a try @faysalmehmood ?

@faysalmehmood
Copy link
Author

faysalmehmood commented Oct 25, 2021

Use of percent encoding will rename file names as slave1%3Adb.properties, slave2%3Adb.properties, master%3Adb.properties if located on a windows OS. But in case we have existing db file names having colon in their names e.g slave1:db.properties and placed on some cloud or github, these cannot be checkedout on windows based systems. This should work seemlessly on both operating systems. As you mentioned earlier, the dot (.) approach would be fine and I am not thinking of any backward compatibility for existing systems at the moment.

While trying the workaround, here is my observation:

The method org.jpos.ee.DB#getMetadata actually prepares the db file name as cfg/slave1%3Adb.properties:db.properties, whereas the actual file path is cfg/slave1%3Adb.properties. Due to this reason, this workaround does not work.

I think the code is exactly for colon in method mentioned above. And in my opinion it might require code-level change to add this support.

else if (configModifier != null) {
	String[] ss = configModifier.split(":");
	if (ss.length > 0)
	dbPropertiesPrefix = ss[0] + ":";
	if (ss.length > 1)
	metadataPrefix = ss[1] + ":";
	hibCfg = System.getProperty("HIBERNATE_CFG","/" + dbPropertiesPrefix + "hibernate.cfg.xml");
	if (getClass().getClassLoader().getResource(hibCfg) == null)
	hibCfg = null;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants