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.

Reply via email to