LR Interface Test---Java vuser before JDBC debugging

Source: Internet
Author: User
Tags throwable

Code that was written under eclipse:

1 import LRAPI.LR;2 import java.sql.Connection;3 import Java.sql.DriverManager;4 import java.sql.PreparedStatement;5 import Java.sql.ResultSet;6 7  Public classActions {8 //define the user name, password, URL of the connection9String username ="Root";TenString Password ="123456"; OneString URL ="Jdbc:mysql://127.0.0.1:3306/oa"; AString sql ="SELECT * from itcast_user where id = 2"; -  Public intinit () throws Throwable { - //1 registering MySQL driver theClass.forName ("Com.mysql.jdbc.Driver"); - return 0; -}//End of Init -  +  Public intaction () throws Throwable { - //2 connecting MySQL, importing java.sql.Connection +Connection conn =drivermanager.getconnection (Url,username,password); A //3 Get the SQL Executor class, import java.sql.preparedstatement atPreparedStatement PS =conn.preparestatement (SQL); - //4 Execute SQL statement, get to execution result object ResultSet (import) -ResultSetSet=ps.executequery (); - //Print the acquired data -  while(Set. Next ()) { -String name =Set. getString ("name"); inSystem. out. println ("name"+name); - } to //turn off Resultset,preparedstatement,connection . + Set. Close (); - ps.close (); the conn.close (); * return 0; $}//End of ActionPanax Notoginseng  -  Public intEnd () throws Throwable { the  + return 0; A}//End of End the  + /* - //program to execute the entrance, in LR do not write $ Public static void Main (string[] args) throws throwable{ $ actions = new actions (); - actions.init (); - actions.action (); the actions.end (); - }*/Wuyi}

Copy to LR and check for syntax errors.

Set LR Run settings: Run-time Settings

Everything is ready, next look to see if the data is queried, as shown in the data return proof script runs through:

The script in this article is intended for debugging purposes only, as there are areas to be optimized, such as adding parameterization, transactions, checkpoints, and so on.

LR Interface Test---Java vuser before JDBC debugging

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.