java.lang.NullPointerException in sql databases
<p>I would like to store a value in database if it is not present if not I would like to insert but I was facing a problem: </p>

<blockquote>
  <p>java.lang.NullPointerException..</p>
</blockquote>

<pre><code>String read = "flavour"; 

public static void dataStore(String read) {

    try {

        Connection connect = null;
        ResultSet rs = null;
        PreparedStatement st = null;

        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        // Setup the connection with the DB
        connect = DriverManager.getConnection("jdbc:sqlserver://WMDENTW1\\SQLEXPRESS:1433;" + "database=FullTextDB;"
                + "user=root;" + "password=root123");
        String key = "IF EXISTS (SELECT * FROM QueryStrings WHERE Query_String= '"+read+"') UPDATE QueryStrings SET Query_Count=Query_Count + 1 WHERE Query_String ='"+read+"' ELSE INSERT INTO QueryStrings VALUES ('"+read+"', 1)";

        st.executeQuery(key);
        System.out.println("data commited");
        connect.commit(); 

    } catch(Exception e) {
        System.out.println(e);
    }
}
</code></pre>