Solve MySQL problems in Loadrunner

Source: Internet
Author: User
Tags mysql host mysql odbc driver

  DocumentIf you use loadrunner to test the MySQL database system, you can install a mysql odbc driver! Then, configure the data source to solve the MySQL problem.

The usage of the MySQL ODBC driver is as follows:
Install Appserv.
We often encounter this problem. How can we use mysql Databases in non-web programs or asp programs? There are two solutions to this problem:

1. Use the api function library provided by mysql.

Many well-known mysql client tools are implemented in this way, as is the well-known winmysql tool. This can be implemented in most development tools. For example, vc, bcb, delphi, and vb can be implemented by calling third-party APIs. But it is not easy for everyone to have high requirements on programmers and be familiar with a set of mysql api functions. This method cannot be used in asp or other programs because it does not support com objects.

2. The second is to use the myodbc driver.

You can go to www.mysql.com to download the myodbc driver and follow the steps below to download the full installation package. This package is large, but only myodbc is useful for us. it is not appropriate to download such a large file. Of course, if you have a good dish, I suggest you choose this method. This is easier, but it does not conform to the cfans style, right.

The second method is to directly download the myodbc. dll file, which is only several hundred kb but not easy to use. after a long time of exploration, I found a method to use it. First, unbind the package and put the myodbc. dll file in the windows \ system or winnt \ system32 directory. It depends on whether your system is win9x or winnt (win2k). You should know.

Open a text editor, such as editplus and notpad, and save the following content as a file with the extension. reg, you see. This is the Registry file. Do not make a mistake (excluding the following long string equals sign)

Reference content is as follows:
If you are using win2k, replace the first line

Windows Registry Editor Version 5.00

========================================================== ========================== Start from the downstream

Windows Registry Editor Version 4.00

[HKEY_LOCAL_MACHINE \ SOFTWARE \ ODBC \ ODBCINST. INI \ myodbc driver]
"UsageCount" = dword: 00000002
"Driver" = "C: \ WINNT \ System32 \ myodbc. dll"
"Setup" = "C: \ WINNT \ System32 \ myodbc. dll"
"SQLLevel" = "1"
"FileUsage" = "0"
"DriverODBCVer" = "02.50"
"ConnectFunctions" = "YYY"
"APILevel" = "1"
"CpTimeout" = "120"
[HKEY_LOCAL_MACHINE \ SOFTWARE \ ODBC \ ODBCINST. INI \ ODBC Drivers]


"Myodbc driver" = "installed"

Double-click the file and register the above Code to the WINDOWS registry.
If it is installed in windows2000, the value of the Driver and Setup primary key must be changed accordingly. I don't want to say much here.
If it succeeds, you will see the myodbd driver in the driver of the control panel/ODBD data source!

Step 2: Create an ASP file link database.
There are two methods, one is to create a system DSN In the ODBC data source. Later, I found that MYSQL can be used in ASP even if it is not created. The method is described below.
Open Control Panel/ODBD data source, select system DSN, and add a new DSN. Select mydbd driver as the driver. A dialog box is displayed for you to enter mysql information.
Windows DSN name: name of the DSN to be created
Mysql Host (name or ip): The name or ip address of the Mysql server.
Mysql database name: the name of the database to be used. The database is created in the Mysql management program. Here is an example. Database Name: hc188
There is a data table: the user data table has two fields: username and password. Just insert a few data.
User: the user name used to connect to the database. I entered the root Super user.
Password: password used to connect to the database. If not, leave it empty.
Port (if not 3306): Mysql Port on the server. if not specified, the default value is 3306.
SQL command on connect: use SQL commands to connect to the database. This parameter is optional.
After entering the information, select OK to save.

The ASP code of the database is linked below!

Reference content is as follows:
<%
StrConnection = "dsn = hc188; driver = {mydbd driver}; server = localhost; uid = root; pwd =; database = hc188"
Set adoDataConn = Server. CreateObject ("ADODB. Connection ")
AdoDataConn. Open strConnection

StrQuery = "SELECT * FROM user"
Set rs = adoDataConn. Execute (strQuery)
If Not rs. BOF Then
%>
<TABLE>
<TR>
<TD <B> username </B> </TD>
<TD> <B> password </B> </TD>
</TR>
<%
Do While Not rs. EOF
%>
<TR>
<TD> <% = rs ("username") %> </TD>
<TD> <% = rs ("password") %> </TD>
</TR>
<%
Rs. MoveNext
Loop
%>
</TABLE>
<%
Else
Response. Write ("Sorry, no data found .")
End If

Rs. Close
AdoDataConn. Close
Set adoDataConn = Nothing
Set rsEmailData = Nothing
%>


Method 2: I thought about using the MYSQL database if the system DSN is not set up? The result is acceptable.
The method is very simple. Change the second line of the above ASP code:
  
Reference content is as follows:
Strconnection = "DefaultDir =; Driver = {myodbc driver}; database = hc188"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.