Share this page

# Working with JDBC

VuGen provides full support for the JDBC protocol. The protocol is used to define how a client may access a database.

In this topic:

## Supported databases

The JDBC protocol supports all databases used with a standard JDBC interface.

It also has custom support for non-standard usage of following databases:

- Postgres
- MySQL
- Oracle
- MSSQL
- H2

Back to top

## Recording JDBC scripts

To record JDBC script use the Java Record Replay protocol.

In Recording Options:

- Under Recording Protocol > Recorder Options, select JDBC and record as with any Java Record Replay script
- To avoid long and repetitive scripts, configure VuGen to generate loops where necessary by selecting Recording Protocol > Code Generation Options > Search for loops

For more information about recording Java Record Replay scripts, see Java Record Replay protocol recording tips.

Back to top

## Known issues

- Blob and Clob class recording is not supported.
- Advanced non-standard features are not supported.

Back to top

## Sample script

    import lrapi.lr;

    public class Actions{

    	public int action() throws Throwable{
    		_properties1 = System.getProperties();
    		_properties1.put("com.comp.lr.java2.record.format", "XML");
    		System.setProperties(_properties1);

    		_driver1 = new org.h2.Driver();
    		_driver2 = org.h2.Driver.load();

    		_string1 = "jdbc:h2:~/test";
    		_string2 = "user";
    		_string3 = lr_unmask("3fbae0ecdbfa75c3");
    		_connection1 = java.sql.DriverManager.getConnection(_string1, _string2, _string3);

    		_string4 = "SELECT count(1) FROM USERS";
    		_preparedstatement1 = _connection5.prepareStatement(_string4);

    		_resultset1 = _preparedstatement1.executeQuery();

    		_boolean1 = _resultset1.next();

    		_int1 = _resultset1.getInt(1);
    		_connection1.close();

    		return 0;
    	}// end of method: public int action() throws Throwable

    	public int init() throws Throwable{
    		return 0;
    	}// end of method: public int init() throws Throwable

    	public int end() throws Throwable{
    		return 0;
    	}// end of method: public int end() throws Throwable

    	/* ------ fields ------ */

    	java.util.Properties _properties1;
    	org.h2.Driver _driver1;
    	org.h2.Driver _driver2;
    	java.lang.String _string1;
    	java.lang.String _string2;
    	java.lang.String _string3;
    	java.sql.Connection _connection1;

    	java.lang.String _string4;
    	java.sql.PreparedStatement _preparedstatement1;
    	java.sql.ResultSet _resultset1;
    	boolean _boolean1;
    	int _int1;
    }

Back to top

See also:

- Supported Java communication protocols
- Java Record Replay protocol recording tips

https://admhelp.microfocus.com VuGen,Professional Performance Engineering,Performance Engineering for Developers 8942
Tips to improve your search results... OpenText™ Virtual User Generator Help Center OpenText™ VuGen Help 26.1 All View Local Help Center View Online Help Center Version: