Click here to Skip to main content
15,886,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have run this code and it can show but the status state "Yes". So I copy the code and change it to status state "No" and run it again .It thrown error like
"
[SQLITE_SCHEMA]  The database schema changed (no such column: Matric_No)
"

So, may I ask what I can do to solve this problem. I do it this different Java class. Is this is problem so cannot run it?

What I have tried:

This code is I had change Status Yes to No. And run it again ,they show error.

public class Notsubmit {



        private Connection connect() {
            // SQLite connection string
            String url = "jdbc:sqlite:C://sqlite/db/test2.db";
            Connection conn = null;
            try {
                conn = DriverManager.getConnection(url);
            } catch (SQLException e) {
                System.out.println(e.getMessage());
            }
            return conn;
        }

        public void notsubmit(String Status) {

            String sql = "SELECT Matric_No, Name"
                    + "FROM nameListss WHERE Status = ?";

            try (Connection conn = this.connect();
                 PreparedStatement pstmt = conn.prepareStatement(sql)) {

                // set the value
                pstmt.setString(1,Status);
                //
                ResultSet rs = pstmt.executeQuery();

                // loop through the result set
                while (rs.next()) {
                    System.out.println(rs.getString("Matric_No") + "\t" +
                            rs.getString("Name")
                           );
                }
            } catch (SQLException e) {
                System.out.println(e.getMessage());
            }
        }
        public static void main(String[] args) {
           Notsubmit add = new Notsubmit();
            add.notsubmit("No");
        }


    }
Posted
Updated 20-Apr-21 4:21am
v2

1 solution

You seem to be having lots of problems just using the correct table and column names in your database. Please check and double check that you are using the same file for each test. This is not something that we can do for you. You can use the SQLite command line interface (sqlite3.exe) to check the schema, and content of any file.

The following commands in sqlite3 will get the information you need.
sqlite3 <name of your database file>
.tables <-- list all tables in this database
.schema <table name> <-- list the schema for the specified table
 
Share this answer
 
v2
Comments
Cow cow Lee 20-Apr-21 10:54am    
ok, but i do know how to run this code it is because not shown anything sqlite3.exe .
But I am sure is same file ,same table it is because copy the code so it seems should be works.
Richard MacCutchan 20-Apr-21 11:01am    
This is not a coding issue, it is purely your database files. And as we have told you before, you are the only person who can check the structure and content of those files.

And there is no point in saying, "it seems should be works". In software development things need to be exact.
Cow cow Lee 20-Apr-21 12:00pm    
OK,thanks for helping

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900