I use NetBeans IDE 12.5 and have Java 17. I use macOS big sur 11.1. I have downloaded the jar file of the Derby database and also developed the connection and a database too, yet it is showing this error again and again. I even downloaded GlassFish. My code is:
import java.sql.*;
public class Main {
public static void main(String args[])
{
try
{
Class.forName("org.apache.derby.jdbc.ClientDriver"); //driver for derby
Connection conn = DriverManager.getConnection("jdbc:derby://localhost:1527/Students","root","");
Statement stat=conn.createStatement();
ResultSet rs=stat.executeQuery("select * from STUD");
while(rs.next())
{
//System.out.print(rs.getInt(1));
System.out.println(rs.getInt(1)+" "+rs.getString(2));
}
}
catch(ClassNotFoundException | SQLException e)
{
System.out.println(e);
}
}
}
Error:
--- exec-maven-plugin:3.0.0:exec (default-cli) @ Vishu_DB ---
java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver
I'm new to this and I don't know how to get rid of this error.
Edit 1:I'm adding the pom.xml code as well
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>Ananya_DB</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<name>Ananya_DB</name>
</project>
Unfortunately I am unable to add any dependencies in this file. If I try and add, it gives me error.