D
Dave Garratt
After a great deal of trawling internet resouces I hope someone can give me
advise and maybe if I'm lucky a small example program. I am writing a small
standalone application (mainly as a learning exercise) and so far I have
created a user logon dialog box that verifies a users details against a
mysql database using jdbc. I want to remove the hard coded references to the
database driver and put these details in a simple XML document that can be
read by the application at startup.
I have created a simple document :-
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE DatabaseParameters SYSTEM "DatabaseParameters.DTD">
<DatabaseParameters>
<jdbcDriver>com.mysql.jdbc.Driver</jdbcDriver>
<jdbcUsername>root</jdbcUsername>
<jdbcPassword/>
<jdbcConnectString>jdbc:mysql://localhost/commander</jdbcConnectString>
</DatabaseParameters>
I have looked at the mass of Java XML technologies and achived some success
with DOM albeit very long winded and not re-usable code. I have seen
references to XSLT and XPATH which on the face of it seem to offer a simple
way of retrieving data from a file like this by passing a directory (tree)
like structure to some method which points to the element/attribute you want
to access.
For example to get the jdbc driver details from the file I assume I would
need to specify /DatabaseParameters/jdbcDriver as the path.
However all the references I have seen on the web about this technology seem
to want to show me how to convert data from XML to HTML or some such web
server equivalent.
Am I misinterpreting this API - can someone send me a small example that
allows me to read the contents of an element or attribute into a java String
variable.
Failing an example a url to a relevant example would be appreciated.
Many thanks in advance,
Dave G.
advise and maybe if I'm lucky a small example program. I am writing a small
standalone application (mainly as a learning exercise) and so far I have
created a user logon dialog box that verifies a users details against a
mysql database using jdbc. I want to remove the hard coded references to the
database driver and put these details in a simple XML document that can be
read by the application at startup.
I have created a simple document :-
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE DatabaseParameters SYSTEM "DatabaseParameters.DTD">
<DatabaseParameters>
<jdbcDriver>com.mysql.jdbc.Driver</jdbcDriver>
<jdbcUsername>root</jdbcUsername>
<jdbcPassword/>
<jdbcConnectString>jdbc:mysql://localhost/commander</jdbcConnectString>
</DatabaseParameters>
I have looked at the mass of Java XML technologies and achived some success
with DOM albeit very long winded and not re-usable code. I have seen
references to XSLT and XPATH which on the face of it seem to offer a simple
way of retrieving data from a file like this by passing a directory (tree)
like structure to some method which points to the element/attribute you want
to access.
For example to get the jdbc driver details from the file I assume I would
need to specify /DatabaseParameters/jdbcDriver as the path.
However all the references I have seen on the web about this technology seem
to want to show me how to convert data from XML to HTML or some such web
server equivalent.
Am I misinterpreting this API - can someone send me a small example that
allows me to read the contents of an element or attribute into a java String
variable.
Failing an example a url to a relevant example would be appreciated.
Many thanks in advance,
Dave G.