Note that there are some explanatory texts on larger screens.

plurals
  1. PONullPointerException from Connection.preparedStatement for SQLite JDBC
    primarykey
    data
    text
    <p>what I'm trying to do is get a ResultSet from a SQL statement from which then I can derive certain values. What I seem to be having troubles with is the preparing of the prepared statement which occurs at this line.</p> <pre><code>String sql = "SELECT " + dataState + " FROM " + table + whereState + ";"; java.sql.PreparedStatement prep = conn.prepareStatement(sql); // Error here </code></pre> <p>I've already checked that the variable conn is not null. All the values in the statement are not null and the stack trace shows this.</p> <blockquote> <p>java.lang.NullPointerException <br>at org.sqlite.PrepStmt.(PrepStmt.java:37) <br>at org.sqlite.Conn.prepareStatement(Conn.java:231) <br>at org.sqlite.Conn.prepareStatement(Conn.java:224) <br>at org.sqlite.Conn.prepareStatement(Conn.java:213) <br>at org.utilities.storagemethods.SQLiteMethod.load(SQLiteMethod.java:223) <br>at org.utilities.DataManager.load(DataManager.java:97) <br>at org.utilities.Test.main(Test.java:21)</p> </blockquote> <p>A print of the sql statement shows that it gives this.</p> <pre><code>SELECT testString, testBool, testObj FROM testTable WHERE testInt=?; </code></pre> <p>You can ascertain the values from the given string.</p> <p>What I can't figure out is what I'm doing wrong to cause this, if you're curious about what sqlite system I'm using, you can find the home page here: <a href="http://www.zentus.com/sqlitejdbc/" rel="nofollow">http://www.zentus.com/sqlitejdbc/</a></p> <p>Thanks in advance for any help on this. I'm completely stumped.</p> <p>Note: In an attempt to save resources, I was caching my Connection's, and re-using them later. When I try re-getting the connection, it works perfectly. Is there a way I can cache them or do I need to load them every time I want to use it?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload