tecfa2: /local/java/classes/mm-jdbc/mysql.jar
Classes Swing (Swing ou le Netscape/Java plugin:
tecfa2: /local/java/JSDK2.0/lib/jsdk.jar
Copies dans http://tecfa.unige.ch/guides/java/classes/
http://tecfa2.unige.ch/guides/java/jdk1.1/docs/api/Package-java.sql.html
http://tecfa2.unige.ch/guides/mysql/local/mm-jdbc/doc/apidoc/
try {
Class.forName("org.gjt.mm.mysql.Driver");
} catch(Exception ex) { ... return; }
String url = "jdbc:mysql://tecfa2.unige.ch:3306/COFFEEBREAK";
String user = "nobody";
String password = null;
Connection
con =
DriverManager.getConnection(
url, user, password
)
;
String queryString = "select COF_NAME, PRICE from COFFEES";
Statement
stmt =
con.createStatement()
;
ResultSet
rs =
stmt.executeQuery(
queryString
)
;
while (rs.next()) {
String s =
rs.getString(
"COF_NAME"
)
;
float n =
rs.getFloat("
PRICE"
)
;
System.out.println(s + " " + n);
}
Plus de détails: 2.3 "Anatomie d'un programme JDBC" [10]