2

java.sqlite.SQLException: no such table: student

I get this error message when I try to show data in my JTable from my fts4 table in sqlite database. I know my code is good because it works on ordinary sqlite table. But I can't access "Virtual tables using fts4". I can access my database but this virtual table with fts4 is giving me a headache. I use Firefox add-on SQLite Manager to create fts4 tables with this query:

CREATE VIRTUAL TABLE student USING fts4 (id, first_name, last_name);

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import net.proteanit.sql.DbUtils;

public class TestGUI extends javax.swing.JFrame {
    Connection con = null;
    PreparedStatement pst = null;
    ResultSet rs = null;
    SqliteConnection sc = new SqliteConnection();

    public TestGUI() {
        initComponents();
        con = SqliteConnection.ConnectSqlite();
        UpdateTable();

    }

    public void UpdateTable(){

        try {
            String sql = "SELECT * from student";
            pst = con.prepareStatement(sql);
            rs=pst.executeQuery();
            studentTable.setModel(DbUtils.resultSetToTableModel(rs));
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e);
        }
    }

Do I need to use some different driver for this? I used this code to connect to sqlite database:

import java.sql.*;
import javax.swing.*;

public class SqliteConnection {
    public Connection con = null;
    PreparedStatement pst = null;
    ResultSet rs = null;

    public static Connection ConnectSqlite(){
        try{
        Class.forName("org.sqlite.JDBC");
        Connection conn = DriverManager.getConnection("jdbc:sqlite:C:\\Documents and Settings\\Zoran Davidovic\\My Documents\\NetBeansProjects\\Test\\baza1.sqlite");
        JOptionPane.showMessageDialog(null, "Connection successful!");
        return conn;
        }
        catch(Exception e){
            JOptionPane.showMessageDialog(null, "Error!");
            return null;
        }
    }


}
8
  • Obviously, the database file that you're actually opening does not have this table.
    – CL.
    Apr 12, 2015 at 5:44
  • It does, but this table is no ordinary tabel, it is virtual table that uses fts4.
    – Zoka
    Apr 12, 2015 at 11:59
  • What evidence do you have for that? The error message proves otherwise.
    – CL.
    Apr 12, 2015 at 12:00
  • What evidence do you need?
    – Zoka
    Apr 12, 2015 at 16:12
  • The error message is evidence that the table is not there. I was asking you why you think that the table is there.
    – CL.
    Apr 12, 2015 at 16:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.