Hi,
Mysql driver erroron Apachi netbeans 18.0
Hi,
I am working onubuntu 18.04. mysql version is:
mysql Ver 14.14Distrib 5.7.42, for Linux (x86_64) using EditLine wrapper
I have written thefollowing code for connecting with database:
importjava.sql.Connection;
importjava.sql.DriverManager;
importjava.sql.SQLException;
import java.sql.*;
public classDbconnect {
booleanconnect(){
Connectioncon = 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;
intqty;
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 thefollowing error:
Starts1...
Exception:com.mysql.jdbc.Driver
Starts2...
BUILD SUCCESSFUL(total time: 13 seconds)
Somebody, pleaseguide me.
Zulfi.