Fetch Records from SQL database and convert into XML file

Ads
 

Fetch Records from SQL database and convert into XML file

Hi Experts, I want a complete end to end code for the below requirement. I would like to explain you the below requirement into 3 steps. cases. I request you to please provide me the code to FULFIL my requirement....

1) Fetch all the records from a SQL VIEW (not from original table) based on the query "SELECT * from AMAR_VIEW WHERE CLASS = 'TENTH" & SIGN = 'AAA' " List of fields below fields as example: - Fields are; - TIMESTAMP,ROLLNO,FROMID,SIGN,CLASS

2) Once you Select lets say 10 records from table / view then you need to Update the selected records only based on the UNIQUR KEY FIELD --> ROLL_NO and what ever the you selected rows those only needs to be update the Signature field SIGN from 'AAA' to 'BBB'

3) Once you Update there immediately then you need to push and output XML file with all records into a single XML with containing as Row's.

Please see the output XML: - I need output XML File as: -

**

<?xml version="1.0" encoding="utf-8"?>
<ns:MT_TestingSQL xmlns:ns="http://abcd.com//SQL_to_File">
    <row>
        <TIMESTAMP>20101107094853</TIMESTAMP>
        <ROLL_NO>112</ROLL_NO>  // UNIQUE KEY FIELD 
        <FROM_ID>SQL01</FROM_ID>    
        <SIGN>AAA</SIGN>        // FLAG = Intially it will comes as W21 once you select 10 records lets say ex: -  then you need to UPDATE Only those Selected fields only with status field SIGN = 'AAA'
        <CLASS>TENTH</CLASS>
    </row>

**

Kindly provide me the JAVA CODE for generating the output XML file.

Regards Amar Srinivas Eli

View Answers

November 7, 2010 at 11:58 AM

I prefer to go for SAX Parser while creating the XML file after fetching the records.

Also please try to use Isolation level as "SERIALIZABLE" Concept while implementing the code it means stating that it will lock the view while accessing the database so that new records will not get insert into the same time while my code is accessing.

Also please update the records in a control way based on ROLL_NO

Thanks in Advance


November 7, 2010 at 11:58 AM

I prefer to go for SAX Parser while creating the XML file after fetching the records.

Also please try to use Isolation level as "SERIALIZABLE" Concept while implementing the code it means stating that it will lock the view while accessing the database so that new records will not get insert into the same time while my code is accessing.

Also please update the records in a control way based on ROLL_NO

Thanks in Advance

Ads









Related Tutorials/Questions & Answers:
How to convert XML file to database ?
How to convert XML file to database ?  How to convert XML file to database
Fetch user records from a table in database
Fetch user records from a table in database  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from
Advertisements
PHP SQL Fetch
; PHP SQL Fetch is used to fetch the records from Mysql database to PHP...',12); php_sql_fetch.php: The code below is used to fetch the records from... The Tutorial illustrate an example from PHP SQL Fetch. To understand and grasp
data insertion from xml file to database table
data insertion from xml file to database table  Hi all, I have data in the XML file. I need to insert it into table in the database using servlet. so please reply me . ThankYou
reading the records from a .xlsx file and storing those records in database table
reading the records from a .xlsx file and storing those records in database table  Here is my requirement, I want to read the records from a .xlsx file and store that records in database table. I tried like this public class
insert rows from browsed file to sql database
insert rows from browsed file to sql database  i need to insert rows from excel to database by browsing the file in jsp. by connecting both..., content of the file has to go to database. how can i insert record into database
PHP WHERE clause example to fetch records from Database Table
Server and will fetch the results from the database table employee date is equal... the data within the MYSQL database table. You can also fetch the results using...You can query a MYSQL database based on multiple conditions. PHP & MYSQL
MySql Databse query to fetch results from database and display it in HTML File
MySql Databse query to fetch results from database and display it in HTML File  Hi. I have a field in database named stages. its datatype is varchar... to retrieve these data from the field table. Actually they are separated by comma
Need solution to get values for XML namespace tags from SQL database in Java
Need solution to get values for XML namespace tags from SQL database... comp:loc=" "/> now i need to get values from sql database for values... and created xml tags in separate file. please provide me solution to get values for xml
fetch data from database in javascript
fetch data from database in javascript   How to fetch data from database in JavaScript when it is a leap year
Data needs to be gathered in XML file from the database (MySql) using JSP
Data needs to be gathered in XML file from the database (MySql) using JSP ... data regarding particular id from the database table. Data needs to be gathered in XML file from the database (MySql) using appropriate JSP/Java Bean functions
how to convert .xml file to csv file
how to convert .xml file to csv file  how to convert .xml file to csv file
how to display records from database
how to display records from database  I want to display records from database in tables, the database is having 2000 records and i want to display 20 records at a time and to use next and previous link buttons to show
Store XML file into Sqlserver Database
Store XML file into Sqlserver Database  Code for storing a typical XML file into SQl server database in 1 or more tables using asp.net using C
Export SQL database schema from SQL server management studion express2005 into MS excel file
Export SQL database schema from SQL server management studion express2005 into MS excel file  HI I need to export Database Schema from SQL Server.... but i need to have Excel file contains database schema. how can i do with SQL
How to create a .mdf file from script (.sql)
How to create a .mdf file from script (.sql)  Hi, I have a sql database in 2008 server. now i want it to convert to 2005. so i script it. just help me to create a .mdf file back from the script
questions from an xml file
questions from an xml file  i am developing online bit by bit exam for that i retrieved questions from an xml file but when i retrieved using jsp i am getting all questions at a time in a single page.but i want to show one
to fetch data from ms word and storing into database
to fetch data from ms word and storing into database  i want to know how to fetch datafields from ms word and storing into database??? please answer soon .its urgent
Solution to get vaues for xml tags fform sql database in java
Solution to get vaues for xml tags fform sql database in java  hi I...; now i need to get values from sql database for values in the blank field... in separate file. please provide me solution to get values for xml tags from
SQL Bulk Insert csv
; SQL Bulk Insert is used to import the records from csv  file... an example from 'SQL Bulk Insert CSV'.To understand and  grasp this example... respectively.Again, we create a file abc  with extension csv contain the records
retrieving xml document from database
retrieving xml document from database  Hi Guys, I want to retrieve the xml document stored in the database on to a jsp page using jdbc/odbc connnection.Please help me in implementing this feature. Thank You Madhu
JAXB Create XML File And Get Data From XML
JAXB Create XML File And Get Data From XML In this section we will read about how to create XML file and how to convert XML file's data to Java Object... to write the Java Objects into a XML file and unmarshal() method to read XML
how to fetch values from .properties to a html file
how to fetch values from .properties to a html file  I have a .properties file with some key value pairs in it. I need to fetch the values from this .properties file into a html file.Please let me know how to do
converting an xml file in relational database objects
converting an xml file in relational database objects  converting an xml file in relational database objects
Want solution to get values for xml namespace tags from database in java
Want solution to get values for xml namespace tags from database in java ...:loc=" "/> now i need to get values from sql database for values in the blank... xml tags in separate file. please provide me solution to get values for xml tags
storing records which of a file into a table of mssql database
storing records which of a file into a table of mssql database  I have a requirement like this, A file contains some records with headers same as column names of a table. I have to store those records into a table
Displaying file from database
Displaying file from database  I have list of files in my database. I... that corresponding file from database. I have list of file id related to search. I want... * from file"; ResultSet rs = stmt.executeQuery(strQuery); while(rs.next
Need Solution to get vaues from sql database in java
file. please provide me solution to get values for xml tags from database...Need Solution to get vaues from sql database in java  hi I have... need to get values from sql database for values in the blank field(" "). how do i
MySql Databse query to fetch results from database
MySql Databse query to fetch results from database  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from
create the SQL tables from an XML schema
create the SQL tables from an XML schema  I'm using Eclipse, Please let me know if anyone developped an application that would automatically create the SQL tables from an XML schema
Storing records of a file inside database table in java
Storing records of a file inside database table in java  Here is my requirement, I have a file which contains some number of records like... the records inside the database except headings (Here sid,sname,age are headings

Ads