Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.SQLException;
- import java.util.Vector;
- import javax.sql.rowset.JdbcRowSet;
- import javax.sql.rowset.RowSetProvider;
- public class tourdumonde {
- JdbcRowSet rowSetMySQL;
- JdbcRowSet rowSetOracle;
- static String ville1 = "Paris";
- public void connectMySQL() throws SQLException {
- rowSetMySQL = RowSetProvider.newFactory().createJdbcRowSet();
- rowSetMySQL.setUrl("jdbc:mysql://localhost:3306/qc");
- rowSetMySQL.setUsername("root");
- rowSetMySQL.setPassword("toto");
- }
- public void connectOracle() throws SQLException {
- rowSetOracle = RowSetProvider.newFactory().createJdbcRowSet();
- rowSetOracle.setUrl("jdbc:oracle:thin:\"qcoloos\"/20051996@192.168.22.60:1521:orcl2");
- }
- public void afficheDestination(String ville) throws SQLException {
- JdbcRowSet rowSetOracle;
- rowSetOracle = RowSetProvider.newFactory().createJdbcRowSet();
- rowSetOracle.setUrl("jdbc:oracle:thin:\"qcoloos\"/20051996@192.168.22.60:1521:orcl2");
- rowSetOracle.setCommand("select * from vol where Ville_depart = ?");
- rowSetOracle.setString(1, ville);
- rowSetOracle.execute();
- JdbcRowSet rowSetMySQL;
- rowSetMySQL = RowSetProvider.newFactory().createJdbcRowSet();
- rowSetMySQL.setUrl("jdbc:mysql://localhost:3306/qc");
- rowSetMySQL.setUsername("root");
- rowSetMySQL.setPassword("toto");
- rowSetMySQL.setCommand("select * from Escales where Ville_escale = ?");
- rowSetMySQL.setString(1, ville);
- rowSetMySQL.execute();
- if(rowSetMySQL.next()){
- while (rowSetOracle.next() ) {
- System.out.println("---------------------------");
- ville1 = (rowSetOracle.getString("Ville_arrivee"));
- System.out.println("NumVol: " + rowSetOracle.getString("NumVol"));
- System.out.println("Ville_depart: " + rowSetOracle.getString("Ville_depart"));
- System.out.println("Ville_arrivee: " + rowSetOracle.getString("Ville_arrivee"));
- System.out.println("Durée escales a : "+rowSetMySQL.getString("Ville_escale") + " est de : " + rowSetMySQL.getString("Duree_escale_minimum"));
- if (!rowSetOracle.getString("Ville_arrivee").equals("Paris")) {
- afficheDestination(ville1);
- }
- }
- }else {
- while (rowSetOracle.next() ) {
- System.out.println("---------------------------");
- ville1 = (rowSetOracle.getString("Ville_arrivee"));
- System.out.println("NumVol: " + rowSetOracle.getString("NumVol"));
- System.out.println("Ville_depart: " + rowSetOracle.getString("Ville_depart"));
- System.out.println("Ville_arrivee: " + rowSetOracle.getString("Ville_arrivee"));
- System.out.println("Pas d'Escale");
- if (!rowSetOracle.getString("Ville_arrivee").equals("Paris")) {
- afficheDestination(ville1);
- }
- }
- }
- }
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- try {
- tourdumonde bdd = new tourdumonde();
- bdd.connectMySQL();
- bdd.connectOracle();
- System.out.println("*Tour du monde Paris*");
- bdd.afficheDestination(ville1);
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement