title: JDBC with VSCode class not found
body: <p>I am having serious trouble creating a Java Project with VS Code with adding the &quot;mysql-connector-java-8.0.21.jar&quot;.
  I have done the following steps:</p>
  <ul>
  <li>Creating a fresh Java project with VS Code from the command line</li>
  <li>Adding the mysql connector by doing &quot;Add referenced libraries&quot;.</li>
  </ul>
  <p>I tried using both jdk 11 and 15 (not 8 since VS Code doesn't support it anymore)</p>
  <p>Launching my code result in the error: <code>java.lang.ClassNotFoundException: com.mysql.cj.LocalizedErrorMessages </code></p>
  <p>Here is an extract of my code:</p>
  <pre><code>import java.lang.reflect.InvocationTargetException;
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.sql.Statement;
  
  public class SimpleJDBCApplication {
  
     static final String DB_URL = &quot;jdbc:mysql://localhost:3306/company&quot;;
     static final String DB_DRV = &quot;com.mysql.jdbc.Driver&quot;;
     static final String DB_USER = &quot;root&quot;;
     static final String DB_PASSWD = &quot;&quot;;
  
     public static void main(String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException,
           IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
  
        Connection connection = null;
        Statement statement = null;
        ResultSet resultSet = null;
  
        try{
            /*To connect with a database using JDBC you need to select get the
                   driver for the respective database and register the driver.
                   The forName() method of the class named Class accepts a class name
                  as a String parameter and loads it into the memory, Soon the is
                  loaded into the memory it gets registered automatically  */  
                  //Take new instance
           System.setProperty(&quot;jdbc.drivers&quot;, &quot;com.mysql.jdbc.Driver&quot;);
           Class.forName(&quot;com.mysql.jdbc.Driver&quot;).getDeclaredConstructor().newInstance();
           connection=DriverManager.getConnection(DB_URL,DB_USER,DB_PASSWD);
           statement=connection.createStatement();
           resultSet=statement.executeQuery (&quot;SELECT * FROM dept&quot;);
           while(resultSet.next()){
              System.out.printf(&quot;%d\t%s\t%s\n&quot;,
              resultSet.getInt(1),
              resultSet.getString(2),
              resultSet.getString(3));
  </code></pre>
  <p>The error occures at the line <code>connection=DriverManager.getConnection(DB_URL,DB_USER,DB_PASSWD);</code></p>
  <p>Thank you for any help</p>
  <p><a href="https://i.stack.imgur.com/56auj.png" rel="nofollow noreferrer">Library added</a>
  <a href="https://i.stack.imgur.com/jH51H.png" rel="nofollow noreferrer">Error</a></p>