title: "java.sql.SQLException: No suitable driver found" error with code but not with gui
body: <p>This question has been asked many times. And I asked this question <a href="https://stackoverflow.com/questions/40383184/java-sql-sqlexception-no-suitable-driver-found-for-jdbcmysql-localhost-dbnam?noredirect=1#comment68095310_40383184">here</a> also. My new question came when I tried using the tutorial given on the official <a href="https://netbeans.org/kb/docs/ide/mysql.html" rel="nofollow noreferrer">netbeans site</a> which uses an gui approach to connect to mysql.I have added the connector in my classpath and tried changing "java.sql.Driver" to "com.mysql.jdbc.Driver". So the question is that how is it even possible that gui works while code doesn't?</p>
  
  <h1>Code:</h1>
  
  <pre><code>try {
          Class.forName("java.sql.Driver");
          Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/game","root","password");
          Statement stmt = con.createStatement();
          String query = "select * from user;";
          ResultSet rs = stmt.executeQuery(query);
          System.out.println(rs);
      } catch (Exception e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <h1>Error:</h1>
  
  <pre><code>java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/game
  at java.sql.DriverManager.getConnection(DriverManager.java:689)
  at java.sql.DriverManager.getConnection(DriverManager.java:247)
  at javaapplication1.JavaApplication1.main(JavaApplication1.java:22)
  </code></pre>