Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.myapplication.data;
- import java.io.Serializable;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import java.sql.Statement;
- import java.util.Random;
- import com.vaadin.data.util.BeanItemContainer;
- @SuppressWarnings("serial")
- public class SubscriberContainer<subscriber_id> extends BeanItemContainer<Subscriber> implements Serializable{
- /**
- * Natural property order for Person bean. Used in tables and forms.
- */
- public static final Object[] NATURAL_COL_ORDER = new Object[] {
- "subscriber_id", "phone_number", "customer_id", "account_number", "account_name",
- "wallet_number"};
- /**
- * "Human readable" captions for properties in same order as in
- * NATURAL_COL_ORDER.
- */
- public static final String[] COL_HEADERS_ENGLISH = new String[] {
- "subscriber_id", "phone_number", "customer_id", "account_number", "account_name",
- "wallet_number"};
- public SubscriberContainer() throws InstantiationException,IllegalAccessException {
- super(Subscriber.class);
- }
- private void initConnectionPool() {
- try {
- connectionPool = new SimpleJDBCConnectionPool(
- "com.mysql.jdbc.Driver ",
- " jdbc:mysql://localhost:3306/juk_app", "root", "");
- } catch (SQLException e) {
- showError("Couldn't create the connection pool!");
- e.printStackTrace();
- }
- }
- private void initDatabase() {
- try {
- Connection con = DriverManager.getConnection(url,"root", "");
- Statement statement = conn.createStatement();
- try {
- statement.executeQuery("SELECT * FROM subscribers");
- } catch (SQLException e) {
- // Failed, which means that we should init the database
- Statement.executeUpdate
- DROP TABLE IF EXISTS subscribers;
- CREATE TABLE subscribers
- (subscriber_id int(15) UNSIGNED NOT NULL AUTO_INCREMENT,
- phone_number varchar(20) NOT NULL ,
- customer_id varchar(15) ,
- account_number varchar(15) NOT NULL,
- account_name varchar(35),
- wallet_number varchar(20) ,
- PRIMARY KEY(subscriber_id),
- UNIQUE (subscriber_id);
- UNIQUE(phone_number) ;
- con.close();
- }catch( Exception e ) {
- e.printStackTrace();
- }}
Add Comment
Please, Sign In to add comment