Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > XML/Java

Reply
Thread Tools

XML/Java

 
 
Maxi
Guest
Posts: n/a
 
      10-05-2003
Hello,
I have this XML file below and I want to read the data from the XML file in
my java code when I connect to my database in my java code.
How do i do that ?

---XML File
<db>
<databaseName>opsa</databaseName>
<username>User</username>
<password>Pass</password>
</db>

------database.java
public void ConnectToDatabase()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn= DriverManager.getConnection ("jdbcdbcpsa", "", "");
stmt = conn.createStatement();
}
catch (Exception ex){}
}


 
Reply With Quote
 
 
 
 
Andrew
Guest
Posts: n/a
 
      10-05-2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Maxi wrote:
| Hello,
| I have this XML file below and I want to read the data from the XML
file in
| my java code when I connect to my database in my java code.
| How do i do that ?
|
| ---XML File
| <db>
| <databaseName>opsa</databaseName>
| <username>User</username>
| <password>Pass</password>
| </db>
|
| ------database.java
| public void ConnectToDatabase()
| {
| try
| {
| Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
| conn= DriverManager.getConnection ("jdbcdbcpsa", "", "");
| stmt = conn.createStatement();
| }
| catch (Exception ex){}
| }
|
|

You could read up on the XML SAX/DOM tutorials which will show you how
to do it. Do you really need to specify these details in an XML file
though, wouldn't a normal properties file do the job, and it is much
simpler.?

- --
[A n d r e w]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/gC8lx4nopx2ZsVURAktIAJwNoJiOgEz2fEJGgoqJ2frCqSfiMA CfRVok
PHzPNBqqsUhsadGVzpScvtM=
=+IL2
-----END PGP SIGNATURE-----

 
Reply With Quote
 
 
 
 
servee
Guest
Posts: n/a
 
      10-07-2003

> You could read up on the XML SAX/DOM tutorials which will show you how
> to do it. Do you really need to specify these details in an XML file
> though, wouldn't a normal properties file do the job, and it is much
> simpler.?

and faster.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments