How to connect db2


#1

Hi i am tried so many times to connect to db2 .But the process is going on not showing any error or any issue so please help me out how can i mange to connecting **

**


DB2 Connection from Katalon
#2

Hello, please provide necessary info. Your information is kind of vague.


#3

A post was split to a new topic: Trying to connect to a db2 system in Katalon Studio - Database - Project Setting


#4

Vali and JOHN_VERGARA

Looks like you might have to import the DB2 drivers via Project–>External Libraries. Once on “External Libraries” click on “Add” button to add the drivers.

You can get the DB2 drivers corresponding to the version of DB2 you are using from
http://www-01.ibm.com/support/docview.wss?uid=swg21363866.

Save the driver you get from above link and add it to your Katalon Studio via External Libraries option.

Let us know how that goes


#5

I have placed external library but still its not working


#6

Katalon Team,

Have we got any resolution for the DB2 connection using katalon studion?


#7

I have a working code that creates a successful connection to DB2. I am using AS400.

	public  void getConnection(List<String> column) {

		Connection connection
		PreparedStatement preparedStmt
		ResultSet resultSet
		ResultSetMetaData resultSetMetaData
		List<String> dbData = new ArrayList<>()

		try {
			Class.forName('Your Driver')
		}
		catch (ClassNotFoundException e) {
			System.out.println("Please check the path of DB2 driver")
			e.printStackTrace()
		}
		System.out.println("DB2 driver is loaded successfully!")

		try {
			connection = DriverManager.getConnection('Host', 'User', 'Password')
			if (connection != null) {
				System.out.println("Connected to the database " + connection.getSchema() + " successfully!")
			}
			else {
				System.out.println("Database connection failed!")
			}
			preparedStmt = connection.prepareStatement('SQL Query Here')
			resultSet =preparedStmt.executeQuery()
			resultSetMetaData = resultSet.getMetaData()

			boolean records = false

			if(resultSet !=null) {

				while(resultSet.next()) {

					records = true;

					for(int i=0; i<column.size(); i++){

						int k = Integer.parseInt(column.get(i).toString())

						dbData.add(resultSet.getString(k));

						println  resultSetMetaData.getColumnName(k) + " = " + dbData.get(i).toString()
					}
				}
			}
			if (records == false) {
				println "No records found";
			}
		}catch (SQLException e) {
			System.out.println("Database connection failed!");
			e.printStackTrace();
		}
	}

Call above method in your test case:
It takes list parameters (Provide column numbers that you want to fetch)

Note: This will fetch every column (that you pass in list) that your query returns. Also, please import supporting drivers to external library.


#8

See above, I have a working code that creates successful connection


#9

Connecting to DB2 through methods in keywords is working fine but not through UI in Katalon Studio - Database - Project Setting. It says “Connection failed! No suitable driver found” even after the required drivers are added to the external library. Is there any fix provided for this issue?


#10

I am also facing same problem. Any solution on DB2 connection from Katalon?


#11

Got it worked. here are the steps.

  1. Download both the db2 jars(db2jcc-db2jcc4.jar and db2jcc_license_cu.jar)
  2. Place these jars in external libraries under project–>Settings–>External Libraries–>add

Once you have successfully imported it, try it. Cheers!!!