Asked 7 years ago
26 Jan 2017
Views 1537
Phpworker

Phpworker posted

connect with SQLite in Java

i have made some code to connect with SQLite in Java
following is what i made

		
				String driver = "org.sqlite.JDBC";
 				
				String url = "jdbc:sqlite:D:/sqllite/example.sqlite";
 
 		        Connection conn;
		        try {
		 
		        	Class.forName(driver);

 		            conn = DriverManager.getConnection(url);
		         
 
 Statement cs = conn.createStatement();
 		            ResultSet rs = cs.executeQuery("SELECT  name,id FROM employee group by name order by id desc");
 
		                   
		        } catch (SQLException e) {
		            e.printStackTrace();
		        } catch (ClassNotFoundException e) {
 					e.printStackTrace();
				}



but getting some error
java.lang.ClassNotFoundException: org.sqlite.JDBC

So whats wrong with it ?
Rasi

Rasi
answered Nov 30 '-1 00:00

probably you missing SQLite jdbc jar file to attach with JRE
So download sqlite-jdbc
and add jar to Java Build path
how to attach jar to application - Phpworker  
Jan 26 '17 13:01
Mitul Dabhi

Mitul Dabhi
answered Nov 30 '-1 00:00

how to attach jar to application for SQLite Database ?

1. download SQLite JDBC form bit bucket
unzip it , you should have .jar file for SQLite

2. now right click on the JRE System Library
click on the build path >> configure build path


Thats it
Post Answer