Results 1 to 7 of 7
  1. #1
    palanikumark is offline Member
    Join Date
    May 2008
    Posts
    12
    Rep Power
    0

    Default How to store extracted xml values in a database?

    Hi friends,
    I created this program using JSTL which extract details from xml... Now i want to store that extracted values in a database.. How can i store that extracted values in a database..? Here is my code...

  2. #2
    gogoc is offline Member
    Join Date
    May 2008
    Posts
    21
    Rep Power
    0

    Default

    you first need to create a db and depending upon the db load the driver and then do the proceedings...
    get new coding problems at CODERWORDS

  3. #3
    palanikumark is offline Member
    Join Date
    May 2008
    Posts
    12
    Rep Power
    0

    Default

    I created database and i cant able to store my values.... So that only i'm asking.... Here i cant able to show my codings....

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  5. #5
    palanikumark is offline Member
    Join Date
    May 2008
    Posts
    12
    Rep Power
    0

    Default How to store extracted xml values in a database?

    Ya i dont know how to store my extracted values in a database... My program extracting details from XML file and displaying that extracted details... Now i want to knw how to store that values in a database using JSTL?

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    So do a simple DB example first. Then try to implement it in your application.

    On the Google you can found lots of such examples. Find one of it and try it. I don't have a sample.

  7. #7
    palanikumark is offline Member
    Join Date
    May 2008
    Posts
    12
    Rep Power
    0

    Default

    Is my code is correct for inserting database... This code does not work and insert data into database...
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <students>
    <student id="1">
    <name>
    <first>Joe</first>
    <last>Y</last>
    <middle>T</middle>
    </name>
    <grade>
    <points>99</points>
    <letter>A</letter>
    </grade>
    </student>
    <student id="2">
    <name>
    <first>James</first>
    <last>Todd</last>
    <middle>K</middle>
    </name>
    <grade>
    <points>92</points>
    <letter>B</letter>
    </grade>
    </student>
    <student id="3">
    <name>
    <first>Kate</first>
    <last>Wang</last>
    <middle>A</middle>
    </name>
    <grade>
    <points>72</points>
    <letter>C</letter>
    </grade>
    </student>

    </students>

    JSTL coding

    <sql:setDataSource driver="sun.jdbc.odbc.JdbcOdbcDriver" url="jdbc:odbc:db1" var="db1" />


    <c:import var="students" url="students.xml" />

    <x:parse var="doc" xml="${students}" />

    <x:set var="a" select="$doc/students/student/name/first" />

    <x:set var="b"
    select="$doc/students/student/name/last" />

    <x:set var="c"
    select="$doc/students/student/name/middle" />
    <sql:update var="query1" dataSource="${db1}" sql="insert into studentDetails values('${a}','${b}')">
    </sql:update>
    <c:out value="record added"/>
    <c:forEach var="row" items="${query1.rowsByIndex}" >
    <tr>
    <td> <c:out value="${row.first}" /></td>
    <td> <c:out value="${row.last}" /></td>
    <td> <c:out value="${row.middle}" /></td>
    </tr>
    </c:forEach>
    Last edited by palanikumark; 05-30-2008 at 12:17 PM.

Similar Threads

  1. Replies: 0
    Last Post: 05-22-2008, 10:53 AM
  2. getting values from database in dropdown
    By aa74 in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 04-21-2008, 10:00 PM
  3. how to populate html:select with values from database
    By sathya_k_83 in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 11-07-2007, 10:53 AM
  4. Replies: 0
    Last Post: 08-15-2007, 01:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •