My requirement is as follows:
I would like to use a JDBC to connect the Oracle which has xml as a table column and retrieve the records. I want all those retrieved xml records to be in one file.
I will parse those extracted xmls using JAXB API and delete some of the tags for every xml i read . Then i would like to generate one single output file which consist of all the xmls that are edited
After retrieving the data from the table my output should look like this
Extracted_records.txt
<Record><tag1></tag1><tag2></tag2><tag3></tag3><Record>
<Record><tag1></tag1><tag2></tag2><tag3></tag3><Record>
<Record><tag1></tag1><tag2></tag2><tag3></tag3><Record>
<Record><tag1></tag1><tag2></tag2><tag3></tag3><Record>
After parsing and deleting the records my output file should look like this
Outputfile.txt
<Record><tag2></tag2><tag3></tag3><Record>
<Record><tag1></tag1><tag2></tag2><Record>
<Record><tag1></tag1><Record>
<Record><tag1></tag1><tag3></tag3><Record>
Related
I have a csv file that has a list of stores. For every Store there are 10 departments.
I will need to make a GET API call for all the 10 departments in 100 stores. So my columns in CSV file are not eve. I will have column A with 100 store IDs, and column B with 10 department IDs.
How can I use every Store ID 10 times (once with every department ID) in Jmeter sampler?
If you want to achieve this using CSV Data Set Config - the only way is splitting your CSV file into 2 separate files
If the CSV file comes from external source and cannot be changed - you can consider using __groovy() function like:
${__groovy(new File('test.csv').readLines().get(vars.get('__jm__Loop Controller - Store__idx') as int).split('\,')[0],)}
Given example CSV file test.csv with the following contents:
store1,department1
store2,department2
,department3
,department4
,department5
,department6
,department7
,department8
,department9
,department10
You can achieve your requirement using below approach:
More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It
I am trying to make a pojo xml file for a pojo class and then create a Hibernate session but the xml file doesn't get updated, the program executes without any error but the table is empty and the data goes inside the previously created table.
What i concluded from this is that my xml file doesn't get updated as soon as create Hibernate session instead it takes the previous data but when the xml is opened new data comes up.
Is there any way of refreshing the xml file so that the new xml data is used in Hibernate?
I have an sql server database table which has xml column name called "Bodytext" which will store xml data.
Now I need to get this "Bodytext" column data and save into System physical path as xml file(Ex: test.xml etc.,)
Any suggestion how to implement this using JAVA?
The column type would be BLOB or CLOB. Retrieve the column data and write the byte data to your file and make it abc.xml
I have a 2 tables, CONFIGURATION_INFO and CONFIGURATION_FILE. I use the below query to find out all employee files
select i.cfg_id, Filecontent
from CONFIGURATION_INFO i,
CONFIGURATION_FILE f
where i.cfg_id=f.cfg_id
but I also need to parse or extract data from the blob column Filecontent and display all cfg_id whose xml tag PCVERSION starts with 8. Is there any way?
XML tag that needs to be extracted is <CSMCLIENT><COMPONENT><PCVERSION>8.1</PCVERSION></COMPONENT></CSMCLIENT>
XML
It need not be any query, even if it is a java or groovy code, it would help me.
Note: Some of the XMLs might be as big as 5MB.
So basically the data from the table CONFIGURATION_INFO, for the column Filecontent is BLOB?
So the syntax to query out the XML from the BLOB Content from database is using this function XMLType.
This function is converting the datatype of your column from BLOB to XMLType. Then parsing it using XPath function.
Oracle Database
select
xmltype(Filecontent, 871).extract('//CSMCLIENT/COMPONENT/PCVERSION/text()').getstringval()
from CONFIGURATION_INFO ...
do the rest of WHERE logic on your own.
Usally you know what the data in the BLOB column, so you can parse in the SQL query..
If it is a text column (varchar or something like that) you can use to_char(coloumName).
There are a lot of functions that you can use you can find them in this link
Usually you will use to_char/to_date/hexToRow/rowTohex
convert blob to file link
I have an xml file which was created from a mysql database with just 1 table.
<database_name>
<table_name>
<col1>row1</col1>
<col2>row1</col1>
</table_name>
<table_name>
<col1>row2</col1>
<col2>row2</col2>
</table_name>
</database_name>
I need to convert this xml file back to a mysql database. How can I do this using Java?
You could use an xml parsing library like dom4j, to parse the file, loop through the results and emit a text file that contains a list of inserts.
Do you know the schema or does it need to be inferred from the data?
So your resultant text file would be something like
create table a ()
insert into a (c1,...cn) values (v1,...vn)
Then you could use mysqldump to push the file into a db
mysqldump -u [username] [databasename] < output.sql
You can write XSL tranformation, and there is no need in Java