Results 1 to 8 of 8

Thread: Help with Error

  1. #1
    Join Date
    Nov 2010
    Posts
    87
    Rep Power
    0

    Default Help with Error

    When I run the following code I am getting this error... please can someone advise. (I have a similar question in the database section of the forum but there are significantly fewer users looking there!)

    Thanks

    ERROR

    Java Code:
    SQL StatementSELECT English FROM smsdb1 WHERE SMS = ?
    Prepared Statementorg.sqlite.PrepStmt@199a0c7c
    Prepared Statementorg.sqlite.PrepStmt@199a0c7c
    java.sql.SQLException: no such column: 'id'
    	at org.sqlite.RS.findColumn(RS.java:116)
    	at org.sqlite.RS.getString(RS.java:247)
    	at PreparedStatementParameter.main(PreparedStatementParameter.java:26)
    My database setup is as follows

    Help with Error-new.jpg

    Java Code:
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
     
    public class PreparedStatementParameter {
        public static void main(String[] args) {
            Connection conn = null;
            PreparedStatement prepStmt = null;
            ResultSet rs = null;
            try {
                Class.forName("org.sqlite.JDBC");
                conn = DriverManager.getConnection("jdbc:sqlite:C:\\smsdb1.sqlite");  
                String sqlStmt = "SELECT English FROM smsdb1 WHERE SMS = ?";
                System.out.println("SQL Statement" + sqlStmt);
                prepStmt = conn.prepareStatement(sqlStmt);
                System.out.println("Prepared Statement" + prepStmt.toString());
     
                prepStmt.setString (1, "2nite");  
                System.out.println("Prepared Statement" + prepStmt.toString());
                rs = prepStmt.executeQuery();
                while (rs.next()) {
                    String id = rs.getString("id");
                    String English = rs.getString("English");
                    System.out.println("Translation: " + id + ", Proper English: " + English );
                }
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                try {
                    if (rs != null)
                        rs.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
                try {
                    if (prepStmt != null)
                        prepStmt.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
                try {
                    if (conn != null)
                        conn.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
    }

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,702
    Rep Power
    8

    Default Re: Help with Error

    Please don't post multiple copies of the same question.

    But the error message seems pretty self-explanatory. Where is your "id" column?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Join Date
    Nov 2010
    Posts
    87
    Rep Power
    0

    Default Re: Help with Error

    I know, I apologise, it's just because of the frustration when I've been working on it all day and there are hardly any members in the other forum.

    I have created an 'id' column though haven't I? It shows it in the image? Have I done this wrong?

    Thanks

    Help with Error-db.jpg
    Last edited by Atia of the julii; 12-02-2011 at 05:55 PM.

  4. #4
    Join Date
    Nov 2010
    Posts
    87
    Rep Power
    0

    Default Re: Help with Error

    As far as I can see I have a column called 'id' , I don't understand why it is telling me it doesn't exist. Any help greatly appreciated.

    Thx

  5. #5
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,702
    Rep Power
    8

    Default Re: Help with Error

    Oh, I see. I only saw Column ID earlier. Sorry.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  6. #6
    Join Date
    Nov 2010
    Posts
    87
    Rep Power
    0

    Default Re: Help with Error

    No worries. I just can't understand why it's not working :(

  7. #7
    Join Date
    Nov 2010
    Posts
    87
    Rep Power
    0

    Default Re: Help with Error

    Problem solved. Thread can be closed/deleted!

  8. #8
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,702
    Rep Power
    8

    Default Re: Help with Error

    Quote Originally Posted by Atia of the julii View Post
    Problem solved. Thread can be closed/deleted!
    What ended up being the problem?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. java out of memory error-heap space error
    By elsanthosh in forum NetBeans
    Replies: 4
    Last Post: 06-15-2010, 09:31 AM
  2. Replies: 1
    Last Post: 03-10-2010, 01:53 PM
  3. Replies: 1
    Last Post: 12-05-2009, 07:28 AM
  4. Replies: 1
    Last Post: 10-26-2009, 04:38 PM
  5. Replies: 3
    Last Post: 01-23-2009, 08:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •