JMeter Refer to two different databases in one Test Plan - jdbc

I want tо refer to two different databases in one sql server in my Test Plan.
I have one Thread Group and 20 steps/samplers, and I want for the first 4 samplers all queries to database to be connect to 'database1' for example and others from step 5 to step 20 all queries are refered to 'database2'.
When I add JDBC connection configuration and try to change dynamically just DatabaseName JMeter accepts the first filled databaseName. For example: If I filled first 'database1' as a name all my connections to databases are to this 'database1' independently from that I change the value of DatabaseName adding new value of the variable 'database'.
I use something like:
jdbc:sqlserver://something.database.windows.net;DatabaseName=${database}

JDBC connection configuration is loaded once before test executed, as other JMeter's configurations
So you must have 2 JDBC connection configurations for each database with 2 different variable names
In JDBC request you can use different variable name when using different database pool names

Related

Return from query that refers tables in two different db

I have a goal where I need to write a query in JDBC postprocessor of JMeter but the tables used in query are in different databases. Some tables are in Db2 and others are in PostgreSQL.
I can connect and get response from two databases i.e. Db2 and PostgreSQL separately. However when I write query, that refer to tables in different db, I see relationship doesn't exist error.
I understand, I can use bound pool variables in JMeter for different db connections.
My question:
How can I use these bound pool variables, which are referring to different db (Db2 and PostgreSQL) connection in JMeter, in a single query, if that is possible. Maybe an example will help here, please?
If what I mention in 1 is not possible in JMeter, then how can I achieve above mentioned overall goal through JMeter?
It is not possible either "through jmeter" or "through" any other database client.
If you need to execute 2 separate queries at the same time - you can add 2 JDBC Connection Configuration elements for 2 databases, 2 JDBC Request samplers and a Synchronizing Timer.

Can JMeter JDBC pre-processor accept multiple Insert/delete/update queries?

Can JMeter JDBC pre-processor accept multiple Insert/delete/update queries?
I have added two queries:
JMeter can do whatever underlying JDBC driver can do, for example for MySQL you can specify allowMultiQueries JDBC URL parameter and you will be able to separate statements by semicolon.
Looking into oracle pool variable name my expectation is that you're trying to test an Oracle database and its JDBC driver doesn't support this feature.
The options are in:
Create a stored procedure which will delete multiple records
Parameterize existing JDBC PreProcessor using i.e. __StringFromFile() function, in this case you will not have to copy and paste the preprocessors
Use JSR223 PreProcessor instead of the JDBC PreProcessor and implement your records deletion logic there, take a look at Statement.addBatch() function, you can combine multiple queries into one statement with it. Check out Using Statement Objects for Batch Updates chapter of the Retrieving and Modifying Values from Result Sets article for more details.
You can submit multiple queries as is, because you can't use ; in JDBC request
But you can use other techniques to insert/delete multiple records, for example using IN
delete from CPAY where bnf_nic_name in ('BillerBBJ929' ,'BillerOFV864')

Jmeter test database read performance

I am going to test database read performance with Jmeter Java Sampler.
Basically, query database 10000 times with primary key as query condition like ID with Thread group and Java Sampler.
I need to load 10000 records into database before executing the Thread Group.
The 10000 records will be looped for the 10000 times database read.
I have looked into the preprocessor of Jmeter. I can insert 10000 records into database in preprocessor, but I do not know how to pass the 10000 IDs to Thread Group or Java Sampler. It is too long to contact IDs as a String parameter.
How I can archive the purpose? Any comment is welcome.
Instead of inserting the data using PreProcessor I would rather recommend preparing the test data in setUp Thread Group. You can write the generated IDs into a file using i.e. Flexible File Writer and then read them back with the CSV Data Set Config
If the database you're testing supports JDBC protocol it makes more sense to use JDBC Request sampler because JDBC Connection Configuration allows using connection pool pattern which most probably your application will be using when talking to the database, the main idea is to set up JMeter to produce the same footprint as the application which will be accessing the database.

Running multiple hive queries using tHiveRow component in Talend

Hi i want to tun multiple hive queries through a single component. Through tHiveRow i'm able to run single query but unable to run multiple queries at a time.
I know that we can run multiple sql queries after going through the following link http://www.vikramtakkar.com/2013/05/example-to-execute-multiple-sql-queries.html
But any one has any idea as how to run multiple queries?
Your link reference shows a MySQL connection... this says nothing about the Hive JDBC driver capabilities, since running multiple statements in one JDBC statement is a driver specific feature!
To run multiple queries:
Start with a tFixedFlowInput component. Configure one String column and choose table input option; you will get a table with one column. Each line, you add, will be one Hive statement. Now connect it with a tHiveRow component and use the column of the ingoing flow in the SQL textarea by <flowName>.<columnName> e.g.: row1.sqlStatement (if the String column in your tFixedFlowInput has the name "sqlStatement" and the connection between the tFixedFlowInput and the tHiveRow component is called "row1").

Oracle: Set Query Timeout

i have a PL/SQL program which do a query to an AS400 database through Transparent Gateway. Sometimes the AS400 not responds to the query (may be network problems )and the PL/SQL program hangs.
Is there any method to set a timeout to the Oracle query so that when certain amount of time passes an exception is risen?
Have you tried setting the HS_FDS_CONNECT_PROPERTIES parameter in the AS400 Transparent Gateway initialisation file?
For a timeout of 2 minutes:
HS_FDS_CONNECT_PROPERTIES="timeout='120'"
Another more general option for setting a query timeout is to create a profile and assign it to the user running your query.
A resource profile can be used to set limits on all sorts of usage in any particular session - one resource limit available is connection time.
For example, you could create a profile as400_tg_profile and assign it a maximum connection time of 2 minutes:
create profile as400_tg_profile limit connect_time 2;
... then you could assign this profile to the user running the query:
alter user as400_tg_user profile as400_tg_profile;
There are lots of options on creating a profile and there are many ways to assign a profile to a particular user so you should read through the documentation.
You could also look into using Oracle Resource Manager creating resource groups and resource profiles if you need to dynamically assign particular resource limits - this gives you fine-grained control of resources for individual sessions.
The Oracle documentation is really good on this - for starters, give this a read:
http://www.oracle.com/technology/products/manageability/database/pdf/twp03/twp_oracle%20database%2010g%20resource%20manager.pdf
For more detail:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/dbrm.htm#ADMIN027
This is one of those bits of functionality that's easier to use in Enterprise Manager, but a quick PL/SQL example is given in:
http://www.dba-oracle.com/job_scheduling/resource_manager.htm

Resources