Click here to Skip to main content
15,848,905 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have two databases and I need to copy data from one table and put it in a table in the other database

I tried doing whatever ive done below but it shows an error

Connection to SQLite has been established.
Exception in thread "main" org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (no such column:)

What I have tried:

ResultSet rs = null;
        Statement st = null;

        String SEL_QUERY = "select TID,Artikullit,Sasiat,cmimit,totalt from T1";
        String UPDATE_QUERY = "insert into Shitja (TSID,Artikullis,Sasias,cmimis,totals) values(?,?,?,?,?)";
        String DELETE_QUERY = "delete from T1";
        try {
            conn.setAutoCommit(false);
            st = conn.createStatement();
            pst = conn.prepareStatement(SEL_QUERY);
            rs = pst.executeQuery();
            pst1 = conn.prepareStatement(UPDATE_QUERY);

            while (rs.next()) {

                int TID = rs.getInt("TID");
                System.out.println(" TID : " + TID);
                pst1.setInt(1, TID);
                pst1.addBatch();

                String Artikullit = rs.getString("Artikullit");
                System.out.println(" Artikullit : " + Artikullit);
                pst1.setString(2, Artikullit);
                pst1.addBatch();

                String Sasiat = rs.getString("Sasiat");
                System.out.println(" Sasiat : " + Sasiat);
                pst1.setString(3, Sasiat);
                pst1.addBatch();

                String cmimit = rs.getString("cmimit");
                System.out.println(" cmimit : " + cmimit);
                pst1.setString(4, cmimit);
                pst1.addBatch();

                String totalt = rs.getString("totalt");
                System.out.println(" totalt : " + totalt);
                pst1.setString(5, totalt);
                pst1.addBatch();
            }

            pst1.executeBatch();
            st.execute(DELETE_QUERY);

            conn.commit();
            conn.close();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e);

        }
Posted
Updated 16-Jun-22 7:21am
v4
Comments
Richard MacCutchan 16-Jun-22 12:39pm    
You have completely changed your question, but you have still not provided any useful details about the table structure, or the error message that you see.

1 solution

 
Share this answer
 
Comments
Richard MacCutchan 16-Jun-22 11:45am    
Did you forget to create the Obstacles table in the output database?
Richard MacCutchan 16-Jun-22 11:52am    
Well as you can see obstacleId is not the same as obstacleID.
Richard MacCutchan 16-Jun-22 11:57am    
Well I cannot see into your database so I cannot guess why that is not working. You can use the sqlite3 command to inspect the database and check the spelling of the tables and columns.

Open a command window in the directory where that database is tored and enter the following commands:
sqlite3 Databases/GroundControlDatabase
.schema
.q
Richard MacCutchan 16-Jun-22 12:11pm    
Done what?
Richard MacCutchan 16-Jun-22 12:12pm    
And you still think I can see your screen or read your mind?

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