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;
        }
    }


}
Zoka
  • 393
  • 3
  • 14

0 Answers0