0

Pls explain me this like i am a retard kid. I am stuck at this point for three days. There so so much documentation for multiple use of JDBC, but when i do it one it won't work for me.

So I build project whit maven vaadin build:

(My project).

Now I need to connect to my MySQL database. I will need to push data once per day. Just for store. I need one simple solution which will be good for my use.

This code work for me all ready but now i am trying whit Pool:

  public class Povezavapool {


        private static final BasicDataSource dataSource = new BasicDataSource();

        static {
            dataSource.setDriverClassName("com.mysql.jdbc.Driver");
            dataSource.setUrl("jdbc:mysql://localhost:3306/patrioti");
            dataSource.setUsername("root");
            dataSource.setPassword("1234567890");
        }

        private Povezavapool() {
            //
        }

        public static Connection getConnection() throws SQLException {
            return dataSource.getConnection();
        }

    }

But now i trying to do smt like this because I read it it is faster and better. I have no idea how to set up it.

public static JDBCConnectionPool getConnectionPool() {
    SimpleJDBCConnectionPool pool = null;
    try {
        pool = new SimpleJDBCConnectionPool("com.mysql.jdbc.Driver",
                "jdbc:mysql://localhost:3306/patrioti", "rooot",
                "1234567890");
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return pool;
}

0 Answers0