What i want is to get data from my database which i saved on my workspace folder, i also intalled the latest sqlite-jdbc jar...
i followed the tuts here http://ift.tt/O2HIwP here is my code..
import java.sql.*;
import javax.swing.*;
public class sqliteConnection {
Connection conn = null;
public static Connection dbConnector(){
try{
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:TR.sqlite","","");
JOptionPane.showMessageDialog(null, "Connection Successful");
Statement stmt = null;
stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM admin_tbl;");
while ( rs.next() ) {
int id = rs.getInt("admin_id");
String user = rs.getString("username");
String pass = rs.getString("password");
System.out.println( "ID = " + id );
System.out.println( "NAME = " + user );
System.out.println( "ADDRESS = " + pass );
System.out.println();
}
rs.close();
stmt.close();
return conn;
}catch(Exception e){
JOptionPane.showMessageDialog(null, e);
System.out.println(e);
return null;
}
}
}
First i get the result of "Connection Successful" then I get this error...
java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (no such table: admin_tbl)
im new in java so please bare with me... ^^v been googling for few hours and still doesn't get any answer,
Aucun commentaire:
Enregistrer un commentaire