Read DB Info from config.xml in a Java extension?

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

ashmelev
Posts: 1
Joined: 11 Apr 2006, 14:29

Read DB Info from config.xml in a Java extension?

Postby ashmelev » 11 Apr 2006, 14:36

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.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 11 Apr 2006, 17:26

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:

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
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 28 guests