作者:花儿在绽放2502857073 | 来源:互联网 | 2023-05-19 05:57
IamusingonesimplecodetoaccesstheSQLitedatabasefromJavaapplication.Mycodeis我使用一个简单的
I am using one simple code to access the SQLite database from Java application . My code is
我使用一个简单的代码从Java应用程序访问SQLite数据库。我的代码是
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class ConnectSQLite
{
public static void main(String[] args)
{
Connection cOnnection= null;
ResultSet resultSet = null;
Statement statement = null;
try
{
Class.forName("org.sqlite.JDBC");
cOnnection= DriverManager.getConnection("jdbc:sqlite:D:\\testdb.db");
statement = connection.createStatement();
resultSet = statement
.executeQuery("SELECT EMPNAME FROM EMPLOYEEDETAILS");
while (resultSet.next())
{
System.out.println("EMPLOYEE NAME:"
+ resultSet.getString("EMPNAME"));
}
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
resultSet.close();
statement.close();
connection.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
}
But this code gives one exception like
但是这段代码给出了一个例外。
java.lang.ClassNotFoundException: org.sqlite.JDBC
How can I slove this,please help me.
我怎么能做到这一点,请帮帮我。
9 个解决方案