simple SQLContainer additem

Hello Vaadin Forum,

I want to try to fill my database table with a new Item but it wont work.
Later on I will try to handle this by setting the propertys to my form.

Here is my code:

 DbHelper.class

	public SQLContainer get_userContainer()
	{
        try {
    		/* TableQuery and SQLContainer for user -table */
            TableQuery q1 = new TableQuery("nutzer", con);
            q1.setVersionColumn("VERSION");
			userContainer = new SQLContainer(q1);
		} catch (SQLException e) {
			System.out.println("Fehler mit userContainer");
			e.printStackTrace();
		}
		return userContainer;
	}
User.class

DbHelper db = AppData.getDbHelper();
	   
SQLContainer sqlcontainer = db.get_userContainer();
			
Object itemid = sqlcontainer.addItem();
 //Next Line Nullpointer
[color=#ff0000]
sqlcontainer.getItem(itemid).addItemProperty("Vorname", new ObjectProperty<String>("Martin"));
[/color]

I’ve tested if(sqlcontainer.getItem(itemid) == null) and it isnt. Its seems its cause of my addItemProperty, but I dont know to handle it right!

Thanks for helping me.

EDIT: Found the following code at
http://dev.vaadin.com/wiki/Addons/SQLContainer

How could that work? Object is an java.lang.Object? It could not know that function getItemProperty…

public static void main(String args[]) {
  SimpleJDBCConnectionPool connPool = new SimpleJDBCConnectionPool();
  SQLContainer container = null;
  try {
    container = new SQLContainer(new TableQuery("users", connPool));
    container.setAutocommit(false);
    Object newUser = container.addItem();
    newUser.getItemProperty("role").setValue("admin");
    container.commit();
  } catch(SQLException e) {
    if (container != null) {
      container.rollback();
    }
    e.printStackTrace();
  }
}

Ok thats only a pre-implementation documentation :frowning: But I still no way to get it work

The item type of SQLContainer (RowItem) doesn’t support adding properties to an Item. Instead the Item already contains the properties and you set the values for it. Either SQLContainer.getItemProperty(itemId, propertyId).setValue(Object) or SQLContainer.getItem(itemId).getItemProperty(propertyId).setValue(Object).

In addition to that, the propertyId will have to be in upper case , I guess.

What does uppercase have to do here?

You guess wrong, I guess.