Vaadin 7 mysql problem

Hi, I am just starting with Vaadin and I try to create a very simple project with MySQL DB in Netbeans.
First there was an error: mysql driver … so I added dependencie - mysql java conector, now my code runs but i can not save data to DB, You can see my code in attachments.
I try to save data to tabel users (user_id, email, name, password, version)
I am using MySQL Container, my DB has just 3 simple tables but no triggers - is it a problem ?
I hope You can help me.

18564.java (1.19 KB)
18565.java (807 Bytes)
18566.java (1.33 KB)
18567.java (457 Bytes)
18568.java (2.83 KB)
18569.java (3.58 KB)
18570.java (1.55 KB)
18571.java (553 Bytes)
18572.java (4.19 KB)

To address the lack of triggers.
I am having the same problem as you as well with identical code. I have added a trigger to Mysql to set the version column . The code does inserts data into the database with all the columns having null values except for the Primary Key “ID” and the verison column.

Can You show me how to create this trigger ?

Run this after loggin into the Mysql database, in mycase i am creade a db called recipebook like the tutorial
– this is the insert trigger
CREATE DEFINER=root@localhost TRIGGER recipebook.ver_ins1 BEFORE INSERT ON recipebook.users FOR EACH ROW
begin
SET new.version = 1;
end;

– the update trigger
CREATE DEFINER=root@localhost TRIGGER recipebook.ver_update1 BEFORE UPDATE ON recipebook.users FOR EACH ROW
begin
IF OLD.version is null then
SET new.version = 1;
ELSE
SET new.version = OLD.version + 1;
END IF;
end;

Error message in the console window log:
I am using Jboss WildFly 8.2.0.Final, Java 1.8.0_31


13:30:48,080 INFO [org.atmosphere.cpr.AtmosphereFramework]
(default task-2) Atmosphere Framework 2.2.4.vaadin4 started.
13:30:48,096 INFO [org.atmosphere.cpr.AtmosphereFramework]
(default task-2) Installed AtmosphereInterceptor Track Message Size Interceptor using | with priority BEFORE_DEFAULT

13:31:20,267 ERROR [stderr]
(default task-8) com.vaadin.data.fieldgroup.FieldGroup$CommitException: Property “email” not bound to datasource.

13:31:20,267 ERROR [stderr]
(default task-8) at com.vaadin.data.fieldgroup.FieldGroup.startTransactions(FieldGroup.java:545)
13:31:20,267 ERROR [stderr]
(default task-8) at com.vaadin.data.fieldgroup.FieldGroup.commit(FieldGroup.java:464)
13:31:20,267 ERROR [stderr]
(default task-8) at org.vaadin.miki.packt.recipebook.views.register.RegisterView.buttonClick(RegisterView.java:138)
13:31:20,267 ERROR [stderr]
(default task-8) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
13:31:20,267 ERROR [stderr]
(default task-8) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
13:31:20,267 ERROR [stderr]
(default task-8) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)


Ok so now I have 2 triggers but I can’t write to DB… There is no error, Vaadin app works but there is no data in DB…

You should have a primary key on the users table with auto increment

CREATE TABLE users (

id bigint(20) unsigned NOT NULL AUTO_INCREMENT,

VERSION bigint(10) DEFAULT 1,
email varchar(250) DEFAULT NULL,
name varchar(64) DEFAULT NULL,
passwd varchar(64) DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

In RegisterView.java and after the line below
Object newUserId = this.container.addItem();
** Add the following in green then run to see if you are getting the Primary key created:

// print primary key in he console window
System.out.println(“Debug - New PrimaryKey value:” + newUserId.toString() );

So I have in my DB tabel users with primary key user_id with AUTO_INCREMENT
When I start my app and click “go to register” I have Email address : NULL and Password: **** No idea why

“Debug - New PrimaryKey value:Temporary row id”

Connection with DB is OK, if I change something here:
“com.mysql.jdbc.Driver”,
“jdbc:mysql://localhost:3306/pcshop”, // ???

           "root",
            ""

then I have error : Property “email” not bound to datasource.

Ok, so you are as the same error point that I am at although you should hve gotten an actual Pk number instead of the string “Temporary row id” I think at this point hopefully a Vaadin export can point out the error or fix as the case may be.
My error:

ERROR [stderr]
(default task-8) com.vaadin.data.fieldgroup.FieldGroup$CommitException: Property “email” not bound to datasource
.

Any ideas from the Vaadin experts?

Andrew did you get any further? Until I can get past this error I will try evaluating a similar product.

I’m having a similar problem. Getting:
com.vaadin.data.fieldgroup.FieldGroup$CommitException: Property “email” not bound to datasource
on buttonClick

Not sure if I’ve created the tables and “version” column correctly (also using mysql, also new to mysql).

If it’s any help, I can successfully login using user credentials that I’ve I manually created on the mysql console. So, I believe the SQLContainer and JDBC stuff is working fine.

You can get the code files here:
https://www.packtpub.com/web-development/building-rich-internet-application-vaadin-video

I’ve sifted through the classes a few times and still can’t see what I’m doing wrong.

Maybe one of you guys will see something that I didn’t.

I’m also having the same problem, also using MySql.
It seems to be a problem related with the auto commit.
If you get rid of it : container.setAutoCommit(false) in SqlContainerService and add a commit in the RegisterView like that :
this.fieldgroup.commit();
((SQLContainer)container).commit();
this.register.setEnabled(false);
then it works, but the code is ugly !
I hope this can help someone find the definitive solution.

Guys I had the same problem, but I realized that I didn’t have jdbc in my project. I resolved that using maven…
Can you check if yours project exist a jdbc.jar to connect to DB?