简体   繁体   English

线程“主”java.lang.ClassNotFoundException 中的异常:org.apache.derby.jdbc.ClientDriver

[英]Exception in thread “main” java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver

My program ever shows these errors when I execute it:我的程序在执行时曾经显示这些错误:

Exception in thread "main" java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at Aula4.main(Aula4.java:13)
Picked up _JAVA_OPTIONS: -Xmx512M
C:\Users\mikae\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1

My file Aula4我的文件Aula4


import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author mikae
 */
public class Aula4 {
    public static void main (String[] args) throws ClassNotFoundException, SQLException {
        try {
            Class.forName("org.apache.derby.jdbc.ClientDriver");
            
            String url = "jdbc:derby://localhost:1527/sistema_academico";
            
            String usuario = "app";
            String senha = "app";
            Connection conexao;
            Scanner ler = new Scanner(System.in);
            int id_aluno;
            double nota;
            String nome;
            int i;
            conexao = DriverManager.getConnection(url, usuario, senha);
            String sql = "INSERT INTO aluno VALUES (?, ?, ?)";
            PreparedStatement stm = conexao.prepareStatement(sql);
            ResultSet rs = stm.executeQuery();
            
            System.out.println("Connected!");
            for (i=0;i<4;i++) { 
                
            System.out.println("Welcome! Type your ID");
            id_aluno = ler.nextInt();
            
            System.out.println("Now, type your name");
            nome = ler.next();

            System.out.println("And finally, type your grade");
            nota = ler.nextDouble();
            
            String SQL_Update = "UPDATE aluno SET nota=? WHERE id_aluno=?";
            stm = conexao.prepareStatement(SQL_Update);
            stm.setLong(1, id_aluno);
            stm.setString(2, nome);
            stm.setBigDecimal(3, new BigDecimal(nota));
            
            int registros = stm.executeUpdate();
            
                        while ( rs.next()) {
                id_aluno = rs.getInt("id_aluno");
                nome= rs.getString("nome");
                nota = rs.getDouble("nota");
            }
            
            stm.close();
            }
            
        } catch (SQLException ex) {
            System.out.println("Connection failed!");
        } 
    }
}

I want to connect my Database.我想连接我的数据库。 I've created my Database and still shows these errors and I'm using Netbeans IDE 8.2.我已经创建了我的数据库,但仍然显示这些错误,我正在使用 Netbeans IDE 8.2。

You need to add the jdbc driver to your java application.您需要将 jdbc 驱动程序添加到您的 java 应用程序中。 If you have a maven project you can add it by adding the following depencency to you pom.xml:如果您有 maven 项目,您可以通过在 pom.xml 中添加以下依赖项来添加它:

<dependency>
    <groupId>org.apache.derby</groupId>
    <artifactId>derbyclient</artifactId>
    <version>10.15.2.0</version>
</dependency>

If you use Netbeans you can download the driver from https://repo1.maven.org/maven2/org/apache/derby/derby/10.15.2.0/ and add it to the poject by following the guide at https://www.foxinfotech.in/2019/03/how-to-add-external-jar-file-in-netbeans-project.html . If you use Netbeans you can download the driver from https://repo1.maven.org/maven2/org/apache/derby/derby/10.15.2.0/ and add it to the poject by following the guide at https://www .foxinfotech.in/2019/03/how-to-add-external-jar-file-in-netbeans-project.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 日志中的Heroku错误:java.lang.ClassNotFoundException:org.apache.derby.jdbc.ClientDriver - Heroku error in logs: java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver 创建数据库时出错:java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver - An error occurred while creating the database: java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver java.lang.ClassNotFoundException:org.apach.derby.jdbc.ClientDriver - java.lang.ClassNotFoundException: org.apach.derby.jdbc.ClientDriver org.apache.derby.jdbc.ClientDriver 在哪里? - where is org.apache.derby.jdbc.ClientDriver? java-找不到类[org.apache.derby.jdbc.ClientDriver] - java - Class [org.apache.derby.jdbc.ClientDriver] not found java.lang.ClassNotFoundException:org.apache.derby.jdbc.EmbeddedDriver - java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver org.apache.derby.jdbc.ClientDriver ; 无法连接 - org.apache.derby.jdbc.ClientDriver ; unable to connect Apache Derby 10.15.* - java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver - Apache Derby 10.15.* - java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver 无法使用org.apache.derby.jdbc.ClientDriver建立与MySQL的连接 - Cannot establish connection to MySQL using org.apache.derby.jdbc.ClientDriver 未找到类[org.apache.derby.jdbc.ClientDriver]。 尝试连接到db时 - Class [org.apache.derby.jdbc.ClientDriver] not found. When trying to connect to db
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM