diff --git a/Doc/Sda1/jdbc.xml b/Doc/Sda1/jdbc.xml index 3ff95988c771359283ea0d3ae47d5ccf75e89f1e..62268ab5606dcfac8172c83503e0e2dc40556dc3 100644 --- a/Doc/Sda1/jdbc.xml +++ b/Doc/Sda1/jdbc.xml @@ -1123,9 +1123,9 @@ public class SimpleInsert { <section xml:id="sectSimpleInsertGui"> <title>A first GUI sketch</title> - <para>So far all data records being transferred to the database server - are still hard-coded in our application. In practice a user wants to - enter data of persons to be submitted to the database.</para> + <para>So far all data records being written to the database server by + our (toy) application are just hard-coded. In practice a GUI is being + required allowing for entering data.</para> <para>We now guide you to develop a first version of a simple GUI for this tasks. A more <link linkend="figureDataInsert2">elaborate @@ -1148,16 +1148,9 @@ public class SimpleInsert { </mediaobject> </figure> - <para>Implementing Swing GUI applications requires knowledge as being - taught in e.g. <link - xlink:href="http://www.hdm-stuttgart.de/studenten/stundenplan/vorlesungsverzeichnis/vorlesung_detail?vorlid=5212221">113300 - Entwicklung von Web-Anwendungen</link>. If you do not (yet) feel - comfortable writing <productname - xlink:href="http://docs.oracle.com/javase/tutorial/uiswing/index.html">Swing</productname> - applications you may want to read <uri - xlink:href="http://www.javamex.com/tutorials/swing">http://www.javamex.com/tutorials/swing</uri> - and <emphasis role="bold">really</emphasis> understand the examples - being presented therein.</para> + <para>Based on your existing JavaFX GUI experience the subsequent GUI + employs the <link xlink:href="https://vaadin.com/book/-/page">Vaadin + application framework</link>.</para> <qandaset defaultlabel="qanda" xml:id="quandaentry_GuiDb"> <title>GUI for inserting Person data to a database server</title> @@ -1165,7 +1158,7 @@ public class SimpleInsert { <qandadiv> <qandaentry> <question> - <para>Write a GUI application as being outlined in <xref + <para>Write a WEB GUI application as being outlined in <xref linkend="simpleInsertGui"/>. You may proceed as follows:</para> <orderedlist> @@ -1195,66 +1188,43 @@ public class SimpleInsert { your <classname>java.awt.event.ActionListener</classname> to actually insert datasets into your database.</para> </listitem> + + <listitem> + <para>Provide problem hints <quote>database connection + failure</quote> to the end user and more detailed log + messages for debugging purposes.</para> + </listitem> </orderedlist> </question> <answer> <para>The complete implementation resides in - <classname>sda.jdbc.intro.v01.InsertPerson</classname>:</para> - - <programlisting language="java">package sda.jdbc.intro.v01; - -import ... - -public class InsertPerson extends JFrame { - - ... - - public InsertPerson () throws SQLException{ - super ("Add a person's data"); - - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - - final JPanel databaseFieldPanel = new JPanel(); - databaseFieldPanel.setLayout(new GridLayout(0,2)); - add(databaseFieldPanel, BorderLayout.CENTER); - - databaseFieldPanel.add(new JLabel("Name:")); - final JTextField nameField = new JTextField(15); - databaseFieldPanel.add(nameField); - - databaseFieldPanel.add(new JLabel("E-mail:")); - final JTextField emailField = new JTextField(15); - databaseFieldPanel.add(emailField); - - final JButton insertButton = new JButton("Insert"); - add(insertButton, BorderLayout.SOUTH); - - final Connection conn = DriverManager.getConnection( - "jdbc:mysql://localhost:3306/hdm", "hdmuser", "XYZ"); - final Statement stmt = conn.createStatement(); - - insertButton.addActionListener(new ActionListener() { - // Linking the GUI to the database server. We assume an open - // connection and a correctly initialized Statement instance - @Override - public void actionPerformed(ActionEvent event) { - final String sql = "INSERT INTO Person VALUES('" + nameField.getText()+ "', '" - + emailField.getText() + "')"; - // We have to catch this Exception because an ActionListener's signature - // prohibits the existence of a "throws" clause. - try { - final int updateCount = stmt.executeUpdate(sql); - JOptionPane.showMessageDialog(null, "Successfully executed \n'" + sql + "'\nand inserted " - + updateCount + " dataset"); - } catch (SQLException e) { - e.printStackTrace(); - } - } - }); - pack(); - } -}</programlisting> + <classname>P/Sda1/InsertGui/V2</classname>. The included + README.md contains hints with respect to starting this + application.</para> + + <para>Notice the separation of problem related messages:</para> + + <programlisting language="java"> ... } catch (SQLException ex) { + Notification.show("Failed to insert record, see log for details", Notification.Type.ERROR_MESSAGE); <co + linkends="sda1JdbcMsgEnduserProgrammer-1" + xml:id="sda1JdbcMsgEnduserProgrammer-1-co"/> + log.error("JDBC exception on data insert:", ex); <co + linkends="sda1JdbcMsgEnduserProgrammer-2" + xml:id="sda1JdbcMsgEnduserProgrammer-2-co"/> + }</programlisting> + + <calloutlist> + <callout arearefs="sda1JdbcMsgEnduserProgrammer-1-co" + xml:id="sda1JdbcMsgEnduserProgrammer-1"> + <para>General message to the end-user.</para> + </callout> + + <callout arearefs="sda1JdbcMsgEnduserProgrammer-2-co" + xml:id="sda1JdbcMsgEnduserProgrammer-2"> + <para>Detailed message to the application developer.</para> + </callout> + </calloutlist> </answer> </qandaentry> </qandadiv> diff --git a/P/Sda1/InsertGui/V2/.gitignore b/P/Sda1/InsertGui/V2/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..c761c2a942224cfaf1bb828ca7fe53c6def3f153 --- /dev/null +++ b/P/Sda1/InsertGui/V2/.gitignore @@ -0,0 +1,6 @@ +/target/ +/.settings/ +src/main/webapp/VAADIN/themes/mytheme/styles.scss.cache +A1.log +.classpath +.project diff --git a/P/Sda1/InsertGui/V2/README.md b/P/Sda1/InsertGui/V2/README.md new file mode 100644 index 0000000000000000000000000000000000000000..9c49b3ff962cf92d5198bb8f8eb0394ac2e8454d --- /dev/null +++ b/P/Sda1/InsertGui/V2/README.md @@ -0,0 +1,37 @@ +addressinsert +============== + +Inserting address records into a relational database. + +Workflow +======== + +To compile the entire project, run "mvn install". +To run the application, run "mvn jetty:run" and open http://localhost:8080/ . + +To develop the theme, simply update the relevant theme files and reload the application. +Pre-compiling a theme eliminates automatic theme updates at runtime - see below for more information. + +Debugging client side code + - run "mvn vaadin:run-codeserver" on a separate console while the application is running + - activate Super Dev Mode in the debug window of the application + +To produce a deployable production mode WAR: +- change productionMode to true in the servlet class configuration (nested in the UI class) +- run "mvn clean vaadin:compile-theme package" + - See below for more information. Running "mvn clean" removes the pre-compiled theme. +- test with "mvn jetty:run-war + +Using a precompiled theme +------------------------- + +When developing the application, Vaadin can compile the theme on the fly when needed, +or the theme can be precompiled to speed up page loads. + +To precompile the theme run "mvn vaadin:compile-theme". Note, though, that once +the theme has been precompiled, any theme changes will not be visible until the +next theme compilation or running the "mvn clean" target. + +When developing the theme, running the application in the "run" mode (rather than +in "debug") in the IDE can speed up consecutive on-the-fly theme compilations +significantly. diff --git a/P/Sda1/InsertGui/V2/Schema/schema.sql b/P/Sda1/InsertGui/V2/Schema/schema.sql new file mode 100644 index 0000000000000000000000000000000000000000..327a0f5ea7e0ed01a24e5ceb86bf2aa646a2f5da --- /dev/null +++ b/P/Sda1/InsertGui/V2/Schema/schema.sql @@ -0,0 +1,7 @@ +CREATE TABLE Person ( + name CHAR(20) NOT NULL, + email CHAR(20) PRIMARY KEY + +); + +SELECT * FROM Person; \ No newline at end of file diff --git a/P/Sda1/InsertGui/V2/pom.xml b/P/Sda1/InsertGui/V2/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..f7cb9ca6519b1301ecc981269c3d179071910686 --- /dev/null +++ b/P/Sda1/InsertGui/V2/pom.xml @@ -0,0 +1,214 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>de.hdm-stuttgart.mi</groupId> + <artifactId>lecturenotes-pom</artifactId> + <version>1.0</version> + <relativePath>../../../pom.xml</relativePath> + </parent> + + <groupId>de.hdm_stuttgart.mi</groupId> + <artifactId>addressinsert</artifactId> + <packaging>war</packaging> + <version>0.9</version> + <name>addressinsert</name> + + <properties> + <vaadin.version>7.5.7</vaadin.version> + <vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version> + <jetty.plugin.version>9.2.3.v20140905</jetty.plugin.version> + <project.source.version>1.8</project.source.version> + <project.target.version>1.8</project.target.version> + <project.encoding>UTF-8</project.encoding> + </properties> + + <repositories> + <repository> + <id>vaadin-addons</id> + <url>http://maven.vaadin.com/vaadin-addons</url> + </repository> + <repository> + <id>vaadin-snapshots</id> + <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url> + <releases> + <enabled>false</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </repository> + </repositories> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-bom</artifactId> + <version>${vaadin.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.0.1</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-server</artifactId> + </dependency> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-push</artifactId> + </dependency> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-client</artifactId> + <scope>provided</scope> + </dependency> + <!-- Needed when using the widgetset optimizer (custom ConnectorBundleLoaderFactory). + For widgetset compilation, vaadin-client-compiler is automatically added + on the compilation classpath by vaadin-maven-plugin so normally there is + no need for an explicit dependency. --> + <!-- <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-client-compiler</artifactId> + <scope>provided</scope> </dependency> --> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-themes</artifactId> + </dependency> + <dependency> + <groupId>mysql</groupId> + <artifactId>mysql-connector-java</artifactId> + <version>5.1.35</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + <version>2.6</version> + <configuration> + <encoding>${project.encoding}</encoding> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-war-plugin</artifactId> + <version>2.3</version> + <configuration> + <failOnMissingWebXml>false</failOnMissingWebXml> + <!-- Exclude some unnecessary files generated by the GWT compiler. --> + <packagingExcludes>WEB-INF/classes/VAADIN/gwt-unitCache/**, + WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes> + </configuration> + </plugin> + <plugin> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-maven-plugin</artifactId> + <version>${vaadin.plugin.version}</version> + <configuration> + <extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs> + <webappDirectory>${basedir}/target/classes/VAADIN/widgetsets</webappDirectory> + <draftCompile>false</draftCompile> + <compileReport>false</compileReport> + <style>OBF</style> + <strict>true</strict> + </configuration> + <executions> + <execution> + <goals> + <goal>update-theme</goal> + <goal>update-widgetset</goal> + <goal>compile</goal> + <!-- disabled by default to use on-the-fly theme compilation --> + <!-- <goal>compile-theme</goal> --> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <version>2.4</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + <version>2.6.1</version> + <!-- Clean up also any pre-compiled themes --> + <configuration> + <filesets> + <fileset> + <directory>src/main/webapp/VAADIN/themes</directory> + <includes> + <include>**/styles.css</include> + <include>**/styles.scss.cache</include> + </includes> + </fileset> + </filesets> + </configuration> + </plugin> + + <!-- The Jetty plugin allows us to easily test the development build by + running jetty:run on the command line. --> + <plugin> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-maven-plugin</artifactId> + <version>${jetty.plugin.version}</version> + <configuration> + <scanIntervalSeconds>2</scanIntervalSeconds> + </configuration> + </plugin> + </plugins> + + <pluginManagement> + <plugins> + <!--This plugin's configuration is used to store Eclipse m2e settings + only. It has no influence on the Maven build itself. --> + <!-- TODO Remove when http://dev.vaadin.com/ticket/14924 is resolved --> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId>com.vaadin</groupId> + <artifactId> + vaadin-maven-plugin + </artifactId> + <versionRange>[7.1.11,)</versionRange> + <goals> + <goal>resources</goal> + <goal>update-widgetset</goal> + <goal>compile</goal> + <goal>compile-theme</goal> + <goal>update-theme</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore></ignore> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + </plugins> + </pluginManagement> + + </build> + +</project> diff --git a/P/Sda1/InsertGui/V2/src/main/java/de/hdm_stuttgart/mi/LoginUI.java b/P/Sda1/InsertGui/V2/src/main/java/de/hdm_stuttgart/mi/LoginUI.java new file mode 100644 index 0000000000000000000000000000000000000000..83239ed5adf61ca0f284f26b568ebf7eeb9390fb --- /dev/null +++ b/P/Sda1/InsertGui/V2/src/main/java/de/hdm_stuttgart/mi/LoginUI.java @@ -0,0 +1,109 @@ +package de.hdm_stuttgart.mi; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; + +import javax.servlet.annotation.WebServlet; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import com.vaadin.annotations.Theme; +import com.vaadin.annotations.VaadinServletConfiguration; +import com.vaadin.annotations.Widgetset; +import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinServlet; +import com.vaadin.server.ClientConnector.DetachListener; +import com.vaadin.ui.Button; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Notification; +import com.vaadin.ui.TextField; +import com.vaadin.ui.UI; + +@Theme("mytheme") +@Widgetset("de.hdm_stuttgart.mi.MyAppWidgetset") +public class LoginUI extends UI implements DetachListener { + + private static final long serialVersionUID = 9013400739498375365L; + + private static Logger log = LogManager.getLogger(LoginUI.class); + + Statement stmt; + + public LoginUI () { + final String jdbcUrl = "jdbc:mysql://localhost:3306/hdm"; + try { + final Connection conn = DriverManager.getConnection( + jdbcUrl, "hdmuser", "XYZ"); + stmt = conn.createStatement(); + } catch (SQLException ex) { + log.error("Unable to connect to database using '" + jdbcUrl + "':", ex); + stmt = null; + } + } + + @Override + public void detach(DetachEvent event) { + if (null != stmt) { + try { + stmt.getConnection().close(); + } catch (final SQLException ex) { + log.error("Unable to disconnect from database:", ex); + } + stmt = null; + } + } + + private final TextField + nameField = new TextField(), + emailField = new TextField(); + + private Button + insertButton = new Button("Insert"); + + @Override + protected void init(final VaadinRequest vaadinRequest) { + final GridLayout layout = new GridLayout(2, 3); + layout.setMargin(true); + setContent(layout); + + if (null == stmt) { + layout.addComponent(new Label("Unable to connect to database server, see log for details"), 0, 0); + return; + } + + layout.addComponent(new Label("Name:"), 0, 0); + layout.addComponent(nameField, 1, 0); + + layout.addComponent(new Label("Email:"), 0, 1); + layout.addComponent(emailField, 1, 1); + + layout.addComponent(insertButton, 1, 2); + + + insertButton.addClickListener(event -> { + final String sql = "INSERT INTO Person VALUES('" + nameField.getValue() + "', '" + + emailField.getValue() + "')"; + // We have to swallow this Exception because an ActionListener's signature + // does not allow for a "throws" clause. + try { + final int updateCount = stmt.executeUpdate(sql); + Notification.show("Successfully executed \n'" + sql + "'\nand inserted " + + updateCount + " dataset"); + + } catch (SQLException ex) { + Notification.show("Failed to insert record, see log for details", Notification.Type.ERROR_MESSAGE); + log.error("JDBC exception on data insert:", ex); + } + }); + } + + @WebServlet(urlPatterns = "/*", name = "LoginUIServlet", asyncSupported = true) + @VaadinServletConfiguration(ui = LoginUI.class, productionMode = false) + public static class LoginUIServlet extends VaadinServlet { + private static final long serialVersionUID = -8657597788907698974L; + } +} diff --git a/P/Sda1/InsertGui/V2/src/main/resources/de/hdm_stuttgart/mi/MyAppWidgetset.gwt.xml b/P/Sda1/InsertGui/V2/src/main/resources/de/hdm_stuttgart/mi/MyAppWidgetset.gwt.xml new file mode 100644 index 0000000000000000000000000000000000000000..763aa41e875c8cb9f06805d0de49ee09e2c72cdf --- /dev/null +++ b/P/Sda1/InsertGui/V2/src/main/resources/de/hdm_stuttgart/mi/MyAppWidgetset.gwt.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN" + "http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd"> +<module> + <inherits name="com.vaadin.DefaultWidgetSet"/> +</module> diff --git a/P/Sda1/InsertGui/V2/src/main/resources/log4j2.xml b/P/Sda1/InsertGui/V2/src/main/resources/log4j2.xml new file mode 100644 index 0000000000000000000000000000000000000000..0988632e7e5ed4f9d05e7a410407e129220d1c87 --- /dev/null +++ b/P/Sda1/InsertGui/V2/src/main/resources/log4j2.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration> + + <Properties> + <Property></Property> + </Properties> + <ThresholdFilter/> + + <Appenders> + + <File name="A1" fileName="A1.log" append="false"> + <PatternLayout pattern="%t %-5p %c{2} - %m%n"/> + </File> + <Console name="STDOUT" target="SYSTEM_OUT"> + <PatternLayout pattern="%C{2} (%F:%L) - %m%n"/> + </Console> + </Appenders> + <Loggers> + + <!-- You my want to define class or package level per-logger rules --> + <Logger name="de.hdm_stuttgart.mi.sda1.xmlstatistics.App" level="info"> + <AppenderRef ref="STDOUT"/> + </Logger> + <Root level="info"> + <AppenderRef ref="A1"/> + </Root> + </Loggers> +</Configuration> \ No newline at end of file diff --git a/P/Sda1/InsertGui/V2/src/main/webapp/VAADIN/themes/mytheme/addons.scss b/P/Sda1/InsertGui/V2/src/main/webapp/VAADIN/themes/mytheme/addons.scss new file mode 100644 index 0000000000000000000000000000000000000000..a5670b70c7eabbe8cf233f10dc9bfeb2fac29f41 --- /dev/null +++ b/P/Sda1/InsertGui/V2/src/main/webapp/VAADIN/themes/mytheme/addons.scss @@ -0,0 +1,7 @@ +/* This file is automatically managed and will be overwritten from time to time. */ +/* Do not manually edit this file. */ + +/* Import and include this mixin into your project theme to include the addon themes */ +@mixin addons { +} + diff --git a/P/Sda1/InsertGui/V2/src/main/webapp/VAADIN/themes/mytheme/favicon.ico b/P/Sda1/InsertGui/V2/src/main/webapp/VAADIN/themes/mytheme/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..ffb34a65c73eb1b3d59dcbb8f18ec78a8b0fc767 Binary files /dev/null and b/P/Sda1/InsertGui/V2/src/main/webapp/VAADIN/themes/mytheme/favicon.ico differ diff --git a/P/Sda1/InsertGui/V2/src/main/webapp/VAADIN/themes/mytheme/mytheme.scss b/P/Sda1/InsertGui/V2/src/main/webapp/VAADIN/themes/mytheme/mytheme.scss new file mode 100644 index 0000000000000000000000000000000000000000..c6aa865f29e4eefba17a1b5e5735c665d4ba87c2 --- /dev/null +++ b/P/Sda1/InsertGui/V2/src/main/webapp/VAADIN/themes/mytheme/mytheme.scss @@ -0,0 +1,36 @@ +// Global variable overrides. Must be declared before importing Valo. + +// Defines the plaintext font size, weight and family. Font size affects general component sizing. +//$v-font-size: 16px; +//$v-font-weight: 300; +//$v-font-family: "Open Sans", sans-serif; + +// Defines the border used by all components. +//$v-border: 1px solid (v-shade 0.7); +//$v-border-radius: 4px; + +// Affects the color of some component elements, e.g Button, Panel title, etc +//$v-background-color: hsl(210, 0%, 98%); +// Affects the color of content areas, e.g Panel and Window content, TextField input etc +//$v-app-background-color: $v-background-color; + +// Affects the visual appearance of all components +//$v-gradient: v-linear 8%; +//$v-bevel-depth: 30%; +//$v-shadow-opacity: 5%; + +// Defines colors for indicating status (focus, success, failure) +//$v-focus-color: valo-focus-color(); // Calculates a suitable color automatically +//$v-friendly-color: #2c9720; +//$v-error-indicator-color: #ed473b; + +// For more information, see: https://vaadin.com/book/-/page/themes.valo.html +// Example variants can be copy/pasted from https://vaadin.com/wiki/-/wiki/Main/Valo+Examples + +@import "../valo/valo.scss"; + +@mixin mytheme { + @include valo; + + // Insert your own theme rules here +} diff --git a/P/Sda1/InsertGui/V2/src/main/webapp/VAADIN/themes/mytheme/styles.scss b/P/Sda1/InsertGui/V2/src/main/webapp/VAADIN/themes/mytheme/styles.scss new file mode 100644 index 0000000000000000000000000000000000000000..bba1d493c0c0dad0be8dae040a2007535c8720ad --- /dev/null +++ b/P/Sda1/InsertGui/V2/src/main/webapp/VAADIN/themes/mytheme/styles.scss @@ -0,0 +1,11 @@ +@import "mytheme.scss"; +@import "addons.scss"; + +// This file prefixes all rules with the theme name to avoid causing conflicts with other themes. +// The actual styles should be defined in mytheme.scss + +.mytheme { + @include addons; + @include mytheme; + +} diff --git a/ws/eclipse/Jdbc/src/main/java/sda/jdbc/intro/v01/InsertPerson.java b/ws/eclipse/Jdbc/src/main/java/sda/jdbc/intro/v01/InsertPerson.java deleted file mode 100644 index c2bfaf5fcc9c774ca9a5704071bebf03d1e9eea6..0000000000000000000000000000000000000000 --- a/ws/eclipse/Jdbc/src/main/java/sda/jdbc/intro/v01/InsertPerson.java +++ /dev/null @@ -1,72 +0,0 @@ -package sda.jdbc.intro.v01; - -import java.awt.BorderLayout; -import java.awt.GridLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.sql.Statement; - -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextField; - -public class InsertPerson extends JFrame { - - private static final long serialVersionUID = -5427181942099955412L; - - public static void main(String[] args) throws SQLException { - InsertPerson app = new InsertPerson(); - app.setVisible(true); - } - - public InsertPerson () throws SQLException{ - super ("Add a person's data"); - - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - - final JPanel databaseFieldPanel = new JPanel(); - databaseFieldPanel.setLayout(new GridLayout(0,2)); - add(databaseFieldPanel, BorderLayout.CENTER); - - databaseFieldPanel.add(new JLabel("Name:")); - final JTextField nameField = new JTextField(15); - databaseFieldPanel.add(nameField); - - databaseFieldPanel.add(new JLabel("E-mail:")); - final JTextField emailField = new JTextField(15); - databaseFieldPanel.add(emailField); - - final JButton insertButton = new JButton("Insert"); - add(insertButton, BorderLayout.SOUTH); - - final Connection conn = DriverManager.getConnection( - "jdbc:mysql://localhost:3306/hdm", "hdmuser", "XYZ"); - final Statement stmt = conn.createStatement(); - - insertButton.addActionListener(new ActionListener() { - // Linking the GUI to the database server. We assume an open - // connection and a correctly initialized Statement instance - @Override - public void actionPerformed(ActionEvent event) { - final String sql = "INSERT INTO Person VALUES('" + nameField.getText()+ "', '" - + emailField.getText() + "')"; - // We have to catch this Exception because an ActionListener's signature - // prohibits the existence of a "throws" clause. - try { - final int updateCount = stmt.executeUpdate(sql); - JOptionPane.showMessageDialog(null, "Successfully executed \n'" + sql + "'\nand inserted " - + updateCount + " dataset"); - } catch (SQLException e) { - e.printStackTrace(); - } - } - }); - pack(); - } -}