Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.flpi.serenity.steps.serenityLibrary;
- import java.sql.*;
- import net.thucydides.core.steps.ScenarioSteps;
- public class databaseInfo extends ScenarioSteps {
- // JDBC driver name and database URL
- static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
- static final String DB_URL = "jdbc:db2://10.77.0.95";
- //Database credentials
- static final String USER = "dkidd";
- static final String PASS = "Puppies13!";
- Connection conn = null;
- Statement stmt = null;
- {
- try {
- //Register JDBC driver
- Class.forName("com.mysql.jdbc.Driver");
- //Open a connection
- conn = DriverManager.getConnection(DB_URL,USER,PASS);
- //Execute a query
- stmt = conn.createStatement();
- String sql;
- sql = "select * from member_sys.member where USERNAME = '270000006912';";
- ResultSet rs = stmt.executeQuery(sql);
- } catch(SQLException se) {
- //Handle errors for JDBC
- se.printStackTrace();
- } catch(Exception e) {
- //Handle errors for Class.forName
- e.printStackTrace();
- } finally {
- //finally block used to close resources
- try { if(stmt!=null)
- stmt.close();
- } catch(SQLException se2) {
- }
- } try {
- if(conn!=null)
- conn.close();
- } catch(SQLException se1){
- Throwable se = null;
- se.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement