如何将SQLite与Java连接起来?
我正在使用一个简单的代码从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();
}
}
}
}
但是这段代码给出了一个例外,比如
java.lang.ClassNotFoundException: org.sqlite.JDBC
我怎么能爱这个,请帮帮我。