AWS using Ansible? Yes, it's possible!

  Although, I've used Ansible extensively for a lot of automation and orchestration tasks, using Ansible for AWS was indeed, a new territory for me.  This turned out to be a blessing, since along with using Ansible for AWS tasks, I also learnt how to use WSL (Windows Subsystem for Linux) on a Windows machine. Though WSL's been around for some time, I still hadn't come around to using it since I was mostly using my Macbook pro. Not anymore, though!  Anyway, I have listed below the steps to: Install WSL on Windows 11 23H2 patch Install AWS CLI on Ubuntu 22.04 (Exact version - 22.04.3 LTS) Install Ansible and the amazon.aws collection Use AWS CLI to get the list of  VPCs in the region - us-east-1 (or a region of your choice) Create a python file/script to get the list of VPCs in the region - us-east-1 (or a region of your choice) Create an Ansible playbook to get the list of VPCs in the region - us-east-1 (or a region of your choice.   You may download the comple...

Check JDBC Connection String using java

Sometimes, I have faced a situation wherein the tnsping to the database is working but the JDBC connection fails. So, in order to check the JDBC connection string, one has to use a java program, which unfortunately isn't my forte.

Thankfully, my friend, Padmaraj, who is a SME on java gave me a small piece of code which works wonderfully well.

Note: Save the below java program as ReadCharacter.java, else the program won't work.


// Program to check the JDBC Connection string.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class ReadCharacter {
public static void main(String[] args) {
Connection dbConnection;
Statement stmt;
String sqlStmt;

// For Oracle 9.2
String thin = "jdbc:oracle:thin:@[db_host]:[db_port]:[oracle_sid]";
String name = "[username]";
String pass = "[password]";
String table = "V$INSTANCE";
try{
pt("Getting Connection....");
Class.forName("oracle.jdbc.driver.OracleDriver");
dbConnection = DriverManager.getConnection(thin, name, pass);
pl(" Got");
pt("Creating statment....");
sqlStmt = "SELECT instance_name, host_name from " + table;
stmt = dbConnection.createStatement();
pl(" Got");
pt("Excuting statment (" + sqlStmt + ")....");
ResultSet rs = stmt.executeQuery(sqlStmt);
pl(" Excuted");
while(rs.next()) {
String n = rs.getString("instance_name");
String a = rs.getString(2);
pl("Instance_Name = " + n + ", Host_Name = " + a );
}
pt("Closing Result set...");
rs.close();
pl(" Closed");
pt("Closed statment....");
stmt.close();
pl(" Closed");
pt("Closing Connection....");
dbConnection.close();
pl(" Closed");
} catch (Exception e) {
e.printStackTrace();
}
}
static void pt(String s) {
System.out.print(s);
}
static void pl(String s) {
System.out.println(s);

}
}


Comments

Popular posts from this blog

Check if UTL_FILE and FND_FILE are working fine

Modify retention period of workflow queues

Clone database home (clone.pl) deprecated in Oracle 19c