public static void cerca_stanza ( int n )
{
try {
Connection conn;
Statement stmt;
ResultSet res;
// load the Connector/J driver
Class.forName("com.mysql.jdbc.Driver").newInstance ();
// establish connection to MySQL
conn = DriverManager.getConnection(
"jdbc:mysql://localhost/hotel", "root", "password");
// execute SELECT query
stmt = conn.createStatement();
res = stmt.executeQuery(
"SELECT * FROM camere " +
"WHERE numero = n");
// process results
while (res.next()) {
String tel = res.getString("telefono");
System.out.println(" Recapito_Telefonico " + tel);
}
res.close();
}
catch(Exception e) {
System.out.println("Error: " + e.toString() );
}