Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC Fetch Records from SQL database and convert into XML file
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Amar Srinivas Eli
Fetch Records from SQL database and convert into XML file
2 Answer(s)      4 years and 2 months ago
Posted in : JDBC


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


Advertisement
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



Related Tutorials/Questions & Answers:
Fetch Records from SQL database and convert into XML file
Fetch Records from SQL database and convert into XML file  Hi Experts... provide me the code to FULFIL my requirement.... 1) Fetch all the records from... file with all records into a single XML with containing as Row's. Please see
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
How to convert XML file to database ?
How to convert XML file to database ?  How to convert XML file to database
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
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
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
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
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 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
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
Data fetch from multiple SQL tables - Hibernate
Data fetch from multiple SQL tables   I am in the process of writing my first hibernate application. I have a sql query that fetches data from... chapter 13 example that fetches data from one table. Please advice. SQL from
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
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
how to convert .xml file to csv file
how to convert .xml file to csv file  how to convert .xml file to csv file
Write records into text file from database
Write records into text file from database You have already learnt how to insert records from text file to database. But here we are going to retrieve records from database and store the data into the text file. For this purpose, we have
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
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
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
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
fetch values from database into text field
fetch values from database into text field  please provide the example for fetching values from database into text field of table as if i am trying following String query = "select * from LTCINFO.PERSONS"; st1
fetch values from database into text field
fetch values from database into text field  please provide the example for fetching values from database into text field of table wth edit... * from LTCINFO.PERSONS"; st1 = con.createStatement(); rs = st1.executeQuery(query
Select tag to fetch data from oracle database
Select tag to fetch data from oracle database  I created a select box... of a student and when regnno is selected from the drop down list by a user... oracle database.Similarly when address will be selected by the user from
Create XML file from flat file and data insert into database
Create XML file from flat file and data insert into database... have developed an application to create xml file from flat file and data...). Create a file "FlatFileXml.java"  used to create an XML and data
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
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
create a xml from sql server 2005 - XML
create a xml from sql server 2005  hello Dear, i want to know how we create a xml file which retrieve data from Sql server 2005 using java. i... with the name as 'student' i want to create a xml file from the table values which
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
How to fetch entries/values from database to a jsp page one by one?
How to fetch entries/values from database to a jsp page one by one?  I have a table in Microsoft SQL server Management Studio with two columns title... to display different database entries of the each column in different blocks. Now
how to convert text file to xml file in java. - XML
how to convert text file to xml file in java.  Hi all, I m having some problem. Problem is I want to convert a text file which is having the no of record(i.e no of different line of information)to a xml file through java
fetch record from oracle database using jsp-servlet?
fetch record from oracle database using jsp-servlet?  how can i fetch data from oracle database by using jsp-servlet. i'm using eclipse, tomcat server and oracle database and creating jsp pages and also using servlet
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
Advertisements
 

 

 

DMCA.com