ResultSet result = preparedStmt.getGeneratedKeys() Getting Id of last Inserted records in the database PreparedStatement preparedStmt = conn.prepareStatement(excuteComm, Statement.RETURN_GENERATED_KEYS) String excuteComm = "INSERT INTO testing.testing(name,company)VALUES(?,?)" Statement fetchData = conn.createStatement() Executing SQL query and fetching the result Loading the required MYSQL JDBC Driver classĬlass.forName(".jdbc.Driver") Ĭonnection conn = DriverManager.getConnection(url) Public static void main(String arg) throws SQLException, Paste the below code in the created file and run the project:. ![]() Now right click on the project and go to the maven.Add the below-mentioned dependency in the pom file of the project:.Create a new maven project in the Eclipse.To run this code we need to create a maven project so that we can add faker dependency to import the faker package in the project. This way we can insert bulk data into the database to test the behavior of the website. Then store this data into the database directly by using the Insert query. ![]() In this code, we are generating the “name” and “company name” using the data faker library. Faker allows us to model this data and create fresh dynamic values for fields every time. This wastes a lot of time in both terms creating test data. For data-driven testing, we need a lot of data that we generate manually or get the file from the internet to fill the fake data. In automation, testing the data generating process is one of the most frustrating processes. ![]() Faker library is used to generating the test data.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |