-1

I am trying to run the following code in intellij in order to connect to a database using JDBC.

    import java.sql.*;
    
    public class DatabaseCompare {
        static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
        static final String DB_URL = "jdbc:mysql://hostname/databasename";
        static final String USER = "user";
        static final String PASS = "databasepass";
    
        public DatabaseCompare() {
        }
    
        public static void main(String[] args) {
            Connection conn = null;
            Statement stmt = null;
    
            try {
                Class.forName("com.mysql.jdbc.Driver");
                System.out.println("Connecting to database...");
                conn = DriverManager.getConnection("jdbc:mysql://hostname/databasename", "user", "databasepass");
                System.out.println("Creating statement...");
                stmt = conn.createStatement();
                String sql = "SELECT c1, c2, c3, c4 FROM table";
                ResultSet rs = stmt.executeQuery(sql);
                rs.close();
                stmt.close();
                conn.close();
            } catch (SQLException var24) {
                var24.printStackTrace();
            } catch (Exception var25) {
                var25.printStackTrace();
            } finally {
                try {
                    if (stmt != null) {
                        stmt.close();
                    }
                } catch (SQLException var23) {
                }
    
                try {
                    if (conn != null) {
                        conn.close();
                    }
                } catch (SQLException var22) {
                    var22.printStackTrace();
                }
    
            }
            System.out.println("Goodbye!");
        }
    }

But when running the query I get over a hundred errors like:

    - Error:(5264, 55) java: package com.google.protobuf.Descriptors does not exist
    - Error:(5267, 43) java: package com.google.protobuf.GeneratedMessageV3 does not exist
    - Error:(49, 26) java: package com.google.protobuf does not exist
    - Error:(118, 9) java: cannot find symbol
      symbol:   class UnusedPrivateParameter
      location: class com.mysql.cj.x.protobuf.MysqlxNotice.Frame
    - Error:(1113, 9) java: cannot find symbol
      symbol:   class UnusedPrivateParameter
      location: class com.mysql.cj.x.protobuf.MysqlxNotice.Warning

I haven't found any relevant info online on how can I fix this issue.

How can I make it dissappear? PS: The username and password are for the sake of demo, I used real credentials when running the script.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
Gabriela R
  • 37
  • 1
  • 4

1 Answers1

-1

The problem was solved by adding the protobuff dependency:

 <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>3.13.0</version>
        </dependency>
Gabriela R
  • 37
  • 1
  • 4