How to run .sql file using java without manually parsing the document - mysql

How to run .sql file using java without manually parsing the document. Is there any prewritten class to do the parsing if it has to be done?

I'm not sure but this may help you.
In MySQL JDBC implementation: setLocalInfileInputStream() sets an InputStream instance that will be used to send data to the MySQL server for a LOAD DATA LOCAL INFILE statement rather than a FileInputStream or URLInputStream that represents the path given as an argument to the statement.

Related

What is an alternative to CSV data set config in JMeter?

We want to use 100 credentials from .csv but I would rather like to know if there is any other alternative to this available in jmeter.
If you have the credentials in the CSV file there are no better ways of "feeding" them to JMeter than CSV Data Set Config.
Just in case if you're still looking for alternatives:
__CSVRead() function. The disadvantage is that the function reads the whole file into memory which might be a problem for large CSV files. The advantage is that you can choose/change the name of the CSV file dynamically (in the runtime) while with the CSV Data Set Config it has to be immutable and cannot be changed once it's initialized.
JDBC Test Elements - allows fetching data (i.e. credentials) from the database rather than from file
Redis Data Set - allows fetching data from Redis data storage
HTTP Simple Table Server - exposes simple HTTP API for fetching data from CSV (useful for distributed architecture when you want to ensure that different JMeter slaves will use the different data), this way you don't have to copy .csv file to slave machines and split it
There are few alternatives
JMeter Plugin for reading random CVS data : Random CSV Data Set Config
JMeter function : __CSVRead
Reading CSV file data from a JSR223 Pre Processor
CSV Data Set Config is simple, easier to user and available out of the box.

How to upload XML to MySQL in react with axios and nodejs

I am trying to upload a XML file to MySQl server.
I have a React web app, I am using Axios and NodeJS.
I was using the follwing statement to import the xml file to the product table directly from the workbench
LOAD XML INFILE "C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/products.xml" INTO TABLE product ROWS IDENTIFIED BY <Product>;
It worked fine.
Now I want to have a button that will upload anew xml file and replace the existing data in the table.
What I tried so far is using the HTML input file element, grabing the file from the event.target.files[0] and sending the file object to the server with a POST request.
I am not realy sure how to go from here I cant find a statement that can import the data out of the file object and imoprt it into the sql table.
any ideas? what is the best way to go about it?
I figured out my problem, my site was deployed to Heroku.
Apparently the clearDB, Heroku's add-on sql database, does not allow the use of LOAD XML INFILE / LOAD DATA INFILE as said here - https://getsatisfaction.com/cleardb/topics/load-data-local-infile.
What I ended up doing was converting the xml file to JS object.
That solution presented a new problem, my xml file was around 3MB summed up to over 12000 rows to insert to the database.
MySQL does not allow inserting more then a 1000 rows in a single query.
I had to split the object to several chuncks and loop through them uploading each one by it self.
This process takes some time to execute and I am sure there are better ways of doing it.
If anyone can shed some light on how best to go about it or provide an alternative I would apprreciate it.

How to save my JSON file after updating (resets after restart program)

So I'm trying to program something using Node.js, I've got a file that is called 'profile.json', that is an object. When something happens, I need to update a value of 'name' to a new name. So I do
'profile.name = name2;'
but after I restart my program everything comes back and I have to change it again. So my problem is how would I save the json after updating it?
It is not saving because you are reading the file and updating it in the application. However, you are not changing anything in the file. Once you read the file and parse the JSON, no link exists to the original file. The JSON exists only in memory. You will want to use the NodeJS File System class to write the file. https://nodejs.org/api/fs.html First, check if the file exists, if it does delete it (or move/rename). Second, save the file using the fs.writeFile method.

select library in SAS from SSIS

I am using SSIS to extract some data out of an SAS server.
using this connection setup (SAS IOM Data Provider 9.3)
I can get the connection to read the default Library/Shared data folder.
What do I need to change/set to get it to read a different library?
These are the properties of the libraries:
The one on the left is the one I can read, the one on the right is the one I am trying to access.
If your data folder contains *.sas7bdat files then you could use this:
http://microsoft-ssis.blogspot.com/2016/09/using-sas-as-source-in-ssis.html
Simply write your SAS libname statement inside the SAS Workspace Init Script box, eg as follows:
libname YOURLIB "/your/path/to/sas/datasets" access=readonly;
More info: http://support.sas.com/kb/33/037.html

How to use bsondump in windows?

How to convert the BSON into JSON from MongoDB.
I inserted documents into MongoDB then I get the following error.
This what I get
C:\mongodb\bin>bsondump collection.bson> collection.json error: boost::filesystem::file_size:
The system cannot find the filespecified:"collection.bson"
please use the absolute directory of collection.bson file or see whether the file is in C:\mongodb\bin or not
Firstly, you have to run the mongodump, which makes the bson file. It creates a dump folder, and it makes for every database an other folder. After that you have to run bsondump coll.bson > coll.json.