I have the below program to connect to oracle database through java in which i have use the thin driver , now the query is that i have to execute the same query in total three different databases more at the same time so i am looking that my application is multi threaded in which the same sql query will be fired but there will be a separate thread for each database and each thread will be have a responsibility from the beginning onwards of establishing the connection with database and firing the query in database so total there are four different database and there will be total four threads , please advise how to achieve this..below is the program im which rite now i am firing the simple query in one databse itself
public class OracleJdbcExample { public static void main(String args[]) throws SQLException { String url = "jdbc:oracle:thin:@localhost:1632:DEVROOT32"; //properties for creating connection to Oracle database Properties props = new Properties(); props.setProperty("user", "scott"); props.setProperty("password", "tiger"); Connection conn = DriverManager.getConnection(url,props); String sql ="select sysdate as current_day from dual"; PreparedStatement preStatement = conn.prepareStatement(sql); ResultSet result = preStatement.executeQuery(); while(result.next()){ System.out.println("Current Date from Oracle : " + result.getString("current_day")); } System.out.println("done"); } }