Hi everybody!
I decided that I want to create a simple dynamic web application with Database connections using MySQL and Apache Tomcat.
I searched in Vaadin Forum about it but I didn’t find or I still don’t understand how it works.
This is my simple web application:
package com.example.connectiondb;
import com.vaadin.Application;
import com.vaadin.ui.*;
@SuppressWarnings("serial")
public class ConnectiondbApplication extends Application {
@Override
public void init() {
Window mainWindow = new Window("Connectiondb Application");
TextField tf1 =new TextField("name");
TextField tf2 = new TextField("phone number");
Button button = new Button("insert");
mainWindow.addComponent(tf1);
mainWindow.addComponent(tf2);
mainWindow.addComponent(button);
setMainWindow(mainWindow);
}
}
I created a database named connection with a table named “person”:
DROP TABLE IF EXISTS person;
CREATE TABLE `person` (
`id` decimal(10,0) NOT NULL AUTO_INCREMENT,
`name` char(20) NOT NULL,
`phoneNumber` decimal(10,0) NOT NULL,
PRIMARY KEY (`id`)
)
I know that the Query would be something like this:
INSERT INTO person (name, phoneNumber ) VALUES ( "Myname", 00011)
I would be so greatful if you help me!!
I use Eclipse.
Thanks.