Define JRE construction project input path for 'JavaSE-1.7'

0

I'm trying to make a connection to MySQL database, but when I use PreparedStatement , eclipse returns: Definir projeto de construção JRE entrada caminho para 'JavaSE-1.7 Yes, I've changed the compiler version to 1.7, but only works with Android 1.5 and 1.6 right? How can I connect to my database? This is my real method for connecting:

private ArrayList<String> sql = new ArrayList<String>();
private Connection con;
  public String getUsuario(String...parametros) throws SQLException {
            sql.add("SELECT "+parametros[1]+"FROM users WHERE 'usuario_id' = "+parametros[0]+";");
               for (String string : sql) {
                try (PreparedStatement stm = con.prepareStatement(string);
                        ResultSet rs = stm.executeQuery()) {
                        while(rs.next()) {
                            System.out.println(rs.getString("usuario_senha"));
                        }
                    }
            }
            return "";
        }
    
asked by anonymous 04.02.2014 / 21:23

1 answer

2

Your problem is not PreparedStatement because it exists in Java 1.6.

The problem is in block try . The form you are using only exists in Java 1.7.

You need to use the traditional way of block try/catch

try{
    PreparedStatement stm = con.prepareStatement(string);
} catch(SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
    
04.02.2014 / 21:49