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.
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.
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;
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 .
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.
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?