Don't print your exceptions this way:

System.err.println("Exception: " + e.getMessage());

This will hide the type of the original exception, and the root exception
(if any). A better way is

e.printStackTrace(System.err);

Which will show that it's a ClassNotFoundException, the exact line where
the exception happened and where it was called from. The more information
you give people trying to help you the better.

The tutorial is using Java with Ant to set up the project. I recommend Java
with Maven otherwise less people will be able to help you because less
people use Ant, and the type of project greatly affects how dependencies
(libraries) are added to the project. But that's beside the point.

The issue seems to be that you added the *folder* containing the jar file,
not the jar file itself. Here are some screenshots to show you the
difference:

[image: image.png]
You can manage the classpath from the project properties
[image: image.png]

Hope it helps

On Sat, Aug 12, 2023 at 10:00 PM Zulfi Khan <zulfi6...@yahoo.com.invalid>
wrote:

>
>
> Hi,
> I checked it in the video my code is right. If any file not included
> kindly let me know explicitly. Please guide me how to include classpath.
>
> *video:*
>
> *https://www.youtube.com/watch?v=rgF-5CwTZeE
> <https://www.youtube.com/watch?v=rgF-5CwTZeE>*
>
>
> *Hi,*
>
> *I was watching this video:Java Database Connectivity || How to connect
> MYSQL and NetBeans 18 || #jdbc #jdbctutorial#jdbcinjava
> <https://www.youtube.com/watch?v=rgF-5CwTZeE> *
>
>
>
>
> *Java Database Connectivity || How to connect MYSQL and NetBeans 18 ||
> #j... <https://www.youtube.com/watch?v=rgF-5CwTZeE>Java Database
> Connectivity || How to connect MYSQL and NetBeans 18 || #j...
> <https://www.youtube.com/watch?v=rgF-5CwTZeE>*
>
>
>
> [image: Play]
>
>
> *and then I downloaded the driver:*
>
> *mysql-connector-j-8.1.0 but I also installed:
> mysql-connector-j-8.0.33-1ubuntu18.004_all and is also part of my project’s
> library.*
>
>
> *I am getting the following output:*
>
> *Starts1...*
>
> *Exception: com.mysql.jdbc.Driver*
>
> *Starts2...*
>
> *BUILD SUCCESSFUL (total time: 32 seconds)*
>
>
> *I have attached the following images, R1..., R2…., R3….:*
>
> *R1: shows ubuntu driver attached to my project’s library, I am trying to
> remove it but the option is greyed.*
>
> *R2:shows installation of another mysql-connector-j*
>
> *R3:shows the poped window when I clicked the services window*
> *I have put my question on the reddit forum but they are not able to guide
> me.*
>
> *Please solve  my problem.*
>
> *Zulfi.*
>
> On Saturday, August 12, 2023 at 11:57:17 PM CDT, Zulfi Khan <
> zulfi6...@yahoo.com> wrote:
>
>
>
> Hi,
> I checked it in the video my code is right. If any file not included
> kindly let me know explicitly. Please guide me how to include classpath.
>
> *video:*
>
> *https://www.youtube.com/watch?v=rgF-5CwTZeE
> <https://www.youtube.com/watch?v=rgF-5CwTZeE>*
>
>
> *Hi,*
>
> *I was watching this video:Java Database Connectivity || How to connect
> MYSQL and NetBeans 18 || #jdbc #jdbctutorial#jdbcinjava
> <https://www.youtube.com/watch?v=rgF-5CwTZeE> *
>
> *Java Database Connectivity || How to connect MYSQL and NetBeans 18 ||
> #j... <https://www.youtube.com/watch?v=rgF-5CwTZeE>*
>
>
> *and then I downloaded the driver:*
>
> *mysql-connector-j-8.1.0 but I also installed:
> mysql-connector-j-8.0.33-1ubuntu18.004_all and is also part of my project’s
> library.*
>
>
> *I am getting the following output:*
>
> *Starts1...*
>
> *Exception: com.mysql.jdbc.Driver*
>
> *Starts2...*
>
> *BUILD SUCCESSFUL (total time: 32 seconds)*
>
>
> *I have attached the following images, R1..., R2…., R3….:*
>
> *R1: shows ubuntu driver attached to my project’s library, I am trying to
> remove it but the option is greyed.*
>
> *R2:shows installation of another mysql-connector-j*
>
> *R3:shows the poped window when I clicked the services window*
> *I have put my question on the reddit forum but they are not able to guide
> me.*
>
> *Please solve  my problem.*
>
>
> *Zulfi.*
>
>
>
>
>
> On Wednesday, August 9, 2023 at 11:37:35 AM CDT, Greenberg, Gary
> <ggree...@visa.com.invalid> wrote:
>
>
>
>    1. This is not a netbeans question you are asking.
>    2. There is not enough info, but IMHO you did not include MySQL jar
>    file in you dependencies in your project.
>
>
>
> *From:* Zulfi Khan <zulfi6...@yahoo.com.INVALID>
> *Sent:* Tuesday, August 8, 2023 9:23 PM
> *To:* NetBeans Mailing List <users@netbeans.apache.org>
> *Subject:* mysql connectivity problem with ApachNetbeans 18:Exception:
> com.mysql.jdbc.Driver
>
>
>
> Hi,
>
>
>
> Mysql driver error on Apachi netbeans 18.0
>
>
>
> Hi,
>
> I am working on ubuntu 18.04. mysql version is:
>
> mysql Ver 14.14 Distrib 5.7.42, for Linux (x86_64) using EditLine wrapper
>
>
>
> I have written the following code for connecting with database:
>
> import java.sql.Connection;
>
> import java.sql.DriverManager;
>
> import java.sql.SQLException;
>
> import java.sql.*;
>
> public class Dbconnect {
>
> boolean connect(){
>
> Connection con = null;
>
> System.out.println("Starts1...");
>
> try {
>
> System.out.println("Starts2...");
>
> Class.forName("com.mysql.jdbc.Driver");
>
> con = DriverManager.getConnection("jdbc:mysql://ebookshop", "root", "");
>
> System.out.println("Starts3...");
>
> if (!con.isClosed()){
>
> System.out.println("Successfully connected to MySQL server...");
>
> Statement stmt = con.createStatement();
>
> String sql = "select * from books";
>
> ResultSet rs = stmt.executeQuery(sql);
>
> String title;
>
> String author;
>
> float price;
>
> int qty;
>
> while(rs.next()){
>
> title = rs.getString("title");
>
> author = rs.getString("author");
>
> price = rs.getFloat("price");
>
> System.out.println("title ="+title+"author="+author+"price="+price);
>
> }
>
> }
>
> } catch(Exception e) {
>
> System.err.println("Exception: " + e.getMessage());
>
> } finally {
>
> try {
>
> if (con != null){
>
> con.close();
>
> return true;
>
> }
>
> } catch(SQLException e) {}
>
> }
>
> return false;
>
> }
>
>
>
> I am getting the following error:
>
>
>
> Starts1...
>
> Exception: com.mysql.jdbc.Driver
>
> Starts2...
>
> BUILD SUCCESSFUL (total time: 13 seconds)
>
>
>
> Somebody, please guide me.
>
>
>
> Zulfi.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org
> For additional commands, e-mail: users-h...@netbeans.apache.org
>
> For further information about the NetBeans mailing lists, visit:
> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



-- 

- Juan Algaba

-- 


*“La información de este correo, así como sus documentos adjuntos, puede 
ser objeto de solicitudes de acceso a la información; así como, de 
solicitudes en el ejercicio de los derechos de Acceso, Rectificación, 
Cancelación, Oposición y Portabilidad de datos personales (derechos 
ARCOP)”.*****

*** ***

*"Este mensaje y cualquier archivo adjunto al mismo 
pueden contener información que podría considerarse confidencial y/o 
reservada. Si ha recibido el mensaje por error, por favor notifique al 
remitente contestando el correo, y destruyendo el mensaje original y sus 
anexos, como una medida de seguridad de carácter administrativo, conforme a 
lo estableció en el artículo 3, fracción XXI de la Ley General de 
Protección de Datos Personales en Posesión de Sujetos Obligados"*.****

** 
**

“La información contenida en este correo electrónico y sus anexos, está 
dirigida únicamente para el uso del individuo o entidad a la que fue 
dirigida y puede contener información propietaria que no es de dominio 
público. Cualquier uso, distribución o reproducción indebida será causa de 
sanción, de acuerdo a lo establecido en el artículo 163, fracción III de la 
Ley General de Protección de Datos Personales en Posesión de Sujetos 
Obligados y artículo 186, fracción IV de la Ley Federal de Transparencia y 
Acceso a la Información Pública”.

Reply via email to