XML/Java

Discussion in 'Java' started by Maxi, Oct 5, 2003.

  1. Maxi

    Maxi Guest

    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 ("jdbc:eek:dbc:eek:psa", "", "");
    stmt = conn.createStatement();
    }
    catch (Exception ex){}
    }
    Maxi, Oct 5, 2003
    #1
    1. Advertising

  2. Maxi

    Andrew Guest

    -----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 ("jdbc:eek:dbc:eek:psa", "", "");
    | 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/gC8lx4nopx2ZsVURAktIAJwNoJiOgEz2fEJGgoqJ2frCqSfiMACfRVok
    PHzPNBqqsUhsadGVzpScvtM=
    =+IL2
    -----END PGP SIGNATURE-----
    Andrew, Oct 5, 2003
    #2
    1. Advertising

  3. Maxi

    servee Guest


    > 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.
    servee, Oct 7, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bomb Diggy
    Replies:
    0
    Views:
    441
    Bomb Diggy
    Jul 28, 2004
  2. Tony Prichard
    Replies:
    0
    Views:
    723
    Tony Prichard
    Dec 12, 2003
  3. Mark Van Orman

    embedding xml in xml as non-xml :)

    Mark Van Orman, Sep 14, 2004, in forum: XML
    Replies:
    5
    Views:
    474
    Patrick TJ McPhee
    Sep 15, 2004
  4. Andy
    Replies:
    0
    Views:
    531
  5. Erik Wasser
    Replies:
    5
    Views:
    450
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page