Instrução: O código a seguir deve ser utilizado para responder às questões de números 54 e 55.
import java.sql.*;
public class Exemplo {
public int opera(String sql) {
int x = 0;
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/banco", "root", "xxx");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(sql);
if (rs.next()) {
return 1;
} else {
return x;
}
} catch (ClassNotFoundException ex) {
return x;
} catch (Exception ex1) {
return x;
}
}
}