Search code examples
mysqljdbcintellij-idearesultset

can't resolve symbol ResultSet in IntelliJ


I created a project that has add mysql-connector-java-5.1.34-bin as a library to the project using IntelliJ 13, but when I tried to import com.mysql.jdbc.ResultSet, the IDE shows that it can not resolve the symbol ResultSet. I'm wondering how to resolve the issue.

[EDIT] when I tried import com.mysql.jdbc.PreparedStatement;, it has no problem.

cheers


Solution

  • Looking inside the MySQL Connector/J .jar file (e.g., by using the Package Explorer tree view in Eclipse) we see that com.mysql.jdbc does contain PreparedStatement.class but does not contain ResultSet.class

    classes.png

    That is, you cannot

    import com.mysql.jdbc.ResultSet
    

    because it doesn't exist. What you really want to do is import PreparedStatement, ResultSet, etc. from java.sql, as in

    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    

    or the lazy option

    import java.sql.*;