EDIT: I had a letter off, it's working now.
I have the following sql statement
UPDATE names set sent_count = sent_count + 1 where user_name = 'name' AND category = 'test' AND service = 'test'
this works by increasing the sent_count each time I run the sql from PGAdmin3, but I have the following method in a Java program using Postgresql JDBC, it's not throwing any exceptions but it's not increasing sent_count here is the method below
public void increaseUsernameResponseCount(String userName, String category, String service, String country) throws SQLException
{
Connection conn = null;
PreparedStatement pst = null;
// ResultSet rs = null;
try
{
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection(url, props);
pst = conn.prepareStatement("UPDATE names set sent_count = sent_count + 1 where user_name = ? AND category = ? AND service = ?");
pst.setString(1, userName);
pst.setString(2, category);
pst.setString(3, service);
int count = pst.executeUpdate();
System.out.println(count);
}
catch (Exception e)
{
System.out.println(e);
}
finally
{
pst.close();
conn.close();
}
}
the count counter prints 0 when this method is ran. Any idea why it does not work from the method but it works when I execute the sql query?
userName,categoryandserviceare exactly the same as in your pgadmin session?System.out.printlnto print the values of username, category, service.