问题描述
首先我要说的是,我是编码的初学者。我只在高中的最后几个学习java,所以不要害怕过于简化的解释。
Let me first start by saying that I am a total beginner to coding. I've studied java for only the last several few of high school, so don't be afraid of an overly simplified explanation.
我正在尝试使用BlueJ创建并连接sqlite数据库作为我的IDE。我真的不明白我在做什么,但我在youtube上遵循了一些说明。无论如何,当我运行程序时,我得到一个java.Lang.ClassNotFoundException:org.sqlite.JDBC。我已经完成了几次谷歌搜索,但大多数解决方案都是指错误放置的jar文件。他们说确保包裹在类路径中,我这样做了......至少我想我做到了。它位于BlueJ的java> extensions文件夹中。请让我知道语法有什么问题或者问题是什么。如果您需要更多信息,请随时询问!
I'm trying to create and connect a sqlite database using BlueJ as my IDE. I don't really understand what I'm doing, but I followed some instructions on youtube. Anyway, when I run the program I get a "java.Lang.ClassNotFoundException: org.sqlite.JDBC." I've done several google searches, but most of the solutions refer to a misplaced jar file. They say "make sure the package is in the classpath," and I did that...atleast I think I did. It's in the java>extensions folder in BlueJ. Please let me know what's wrong with syntax or whatever the problem could be. If you need more information feel free to ask!
非常感谢,
谢谢!
Help much appreciated,Thanks!
这是我的代码:
import java.sql。*;
import java.sql.*;
import javax.swing。*;
import javax.swing.*;
public class javaconnect2
{
public class javaconnect2 {
public static Connection ConnecrDB()
{
Connection conn = null;
try
{
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:/Users/aaronyih/Desktop/TEA/LearningGUI/TEA DATABASE.sqlite");
JOptionPane.showMessageDialog(null, "Connection Established!");
return(conn);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e);
return(null);
}
}
}
推荐答案
您的应用程序的运行时类路径没有SQLLite驱动程序jar。保持在那里,你的代码将执行。
Your application's runtime classpath does not have the SQLLite driver jar. Keep it there and thy code shall execute.
这篇关于sqlite数据库连接:java.Lang.ClassNotFoundException:org.sqlite.JDBC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!