1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| //Creation du package Orcl_conn
package Orcl_Conn;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class OracleConnexion {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Connection connection = null;
Statement statement = null;
System.out.println("Connection en cours ...");
try {
Class.forName("oracle.jdbc.OracleDriver");
connection = DriverManager.getConnection("jdbc:oracle:thin:@"le serveur":"port":Instance","user","password");
statement = connection.createStatement();
String requete = "1 ère requete pour la 1ère feuille d'Excel";
ResultSet rs = statement.executeQuery(requete);
while (rs.next()) {
String tiers = rs.getString(1);
String duration = rs.getString(2);
System.out.println(""+ tiers +" "+ duration +"");
} } catch (SQLException e) {
System.out.println("SQL Exception: "+ e.toString());
} catch (ClassNotFoundException cE) {
System.out.println("Class Not Found Exception: "+ cE.toString());
}
}
} |
Partager