import java.io.* ;
import java.sql.* ;
public class JDBC_1 {
private Connection con ;
/**
* Chargement du pilote JDBC puis creation de la connection
*/
public void init()
{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
con = DriverManager.getConnection("jdbc:odbc:diffu","","") ;
}
catch(ClassNotFoundException e0) {
System.out.println("--> ClassNotFoundException : " + e0) ;
}
catch(SQLException e1) {
System.out.println("--> SQLException : " + e1) ;
}
catch(Exception e2) {
System.out.println("--> Exception : " + e2) ;
}
}
//----------------------------------------------------------------------
public boolean sql(String query) {
try {
Statement st = con.createStatement() ;
ResultSet rs = st.executeQuery(query) ;
while (rs.next()) {
System.out.println("--> " + rs.getString(1) ) ;
}
}
catch(SQLException e1) {
System.out.println("--> SQLException : " + e1) ;
}
return true ;
}
public static void main(String args[])
{
JDBC_1 tq = new JDBC_1();
tq.init();
tq.sql("select smail from diffu");
}
}
//----------------------------------------------------------------------
Generated by srcColor