Results 1 to 8 of 8
Thread: Help with Error
- 12-02-2011, 06:39 PM #1
Member
- Join Date
- Nov 2010
- Posts
- 87
- Rep Power
- 0
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)
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(); } } } }
- 12-02-2011, 06:41 PM #2
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 - GameDev tutorials, free Java and JavaScript hosting!
Static Void Games forum - Come say hello!
- 12-02-2011, 06:51 PM #3
Member
- Join Date
- Nov 2010
- Posts
- 87
- Rep Power
- 0
Re: Help with Error
Last edited by Atia of the julii; 12-02-2011 at 06:55 PM.
- 12-02-2011, 07:18 PM #4
Member
- Join Date
- Nov 2010
- Posts
- 87
- Rep Power
- 0
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
- 12-02-2011, 07:41 PM #5
Re: Help with Error
Oh, I see. I only saw Column ID earlier. Sorry.
How to Ask Questions the Smart Way
Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
Static Void Games forum - Come say hello!
- 12-02-2011, 08:04 PM #6
Member
- Join Date
- Nov 2010
- Posts
- 87
- Rep Power
- 0
Re: Help with Error
No worries. I just can't understand why it's not working :(
- 12-02-2011, 09:44 PM #7
Member
- Join Date
- Nov 2010
- Posts
- 87
- Rep Power
- 0
Re: Help with Error
Problem solved. Thread can be closed/deleted!
- 12-05-2011, 02:59 PM #8
Re: Help with Error
How to Ask Questions the Smart Way
Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
Static Void Games forum - Come say hello!
Similar Threads
-
java out of memory error-heap space error
By elsanthosh in forum NetBeansReplies: 4Last Post: 06-15-2010, 10:31 AM -
> Operator cannot be applied error and return incompatible types error
By corney_16 in forum New To JavaReplies: 1Last Post: 03-10-2010, 02:53 PM -
Thread: Error 500--Internal Server Error java.lang.NullPointerException
By jackdear44 in forum New To JavaReplies: 1Last Post: 12-05-2009, 08:28 AM -
java.lang.Error: Error opening DSound for capture
By NARs in forum NetworkingReplies: 1Last Post: 10-26-2009, 05:38 PM -
Diference Between compiler error Garbage collection and Runtime Error?
By makpandian in forum New To JavaReplies: 3Last Post: 01-23-2009, 09:53 AM
Bookmarks