Read DB Info from config.xml in a Java extension?
Read DB Info from config.xml in a Java extension?
Is there a way to read the Database connection information from the config.xml file from within a Java extension? I have a need for some fairly extensive database usage (including transactions and an existing library of code). It's not a show stopper if it cannot be done, I would just like to have a single point of settings maintenance for the application.
Hi,
I would suggest two possible solutions.
1) Simply read the config.xml file from disk and parse it with your favourite XML parser.
Probably it's not the best solution as the XML file can be pretty long and complex.
2) Create the DatabaseManager instance dynamically from your extension code instead of using the confg.xml file.
In this thread we discussed how the db connection can be established without the need of the external xml file.
If you're coding the extension in Actionscript you can copy/paste the code snippet. If you're using Java you can easily translate it.
This code:
would translate into Java:
and you will need to add the following import:
hope it helps
I would suggest two possible solutions.
1) Simply read the config.xml file from disk and parse it with your favourite XML parser.
Probably it's not the best solution as the XML file can be pretty long and complex.
2) Create the DatabaseManager instance dynamically from your extension code instead of using the confg.xml file.
In this thread we discussed how the db connection can be established without the need of the external xml file.
If you're coding the extension in Actionscript you can copy/paste the code snippet. If you're using Java you can easily translate it.
This code:
Code: Select all
dbase2 = new __db.DbManager( ... )
would translate into Java:
Code: Select all
DbManager dbase2 = new DbManager( ... )
and you will need to add the following import:
Code: Select all
import it.gotoandplay.smartfoxserver.db.DbManager
hope it helps
Return to “Server Side Extension Development”
Who is online
Users browsing this forum: No registered users and 63 guests