Vaadin + SQL = SQLNonTransientConnectionException?

Hallo there dear Vaadin Board,
i recently started using the Framework and implemented an UI which was fun and also good looking and safed me a lot of work. Now i’m trying to connect my Application to a Database. I surfed the Net for so long and found so many topics on this, but nothing actually helped :frowning:

So i’ve got some Classes. The ConnectToServer-Class is the one which creates the Database Connection and can return it if asked.

public class ConnectToServer {
    //Database credentials
    private static final String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver";
    private static final String DB_IP = "jdbc:mysql://......";
    private static final String USER = "user";
    private static final String PASS = "password";
    private SimpleJDBCConnectionPool connection = null;
    public ConnectToServer() {
    public void Connect() throws Exception{
            connection = new SimpleJDBCConnectionPool(JDBC_DRIVER,DB_IP,USER,PASS);
            System.out.println("Connected to database!");
    public SimpleJDBCConnectionPool getConnection(){
        System.out.println("Here is your connection Object!");
        return this.connection;

i then try to Access this new connection with another Class, especially with this one Method.

public SQLContainer getUserTable(String table) throws Exception{
        server = new ConnectToServer();
        try {
        } catch (Exception e) {
            // TODO Auto-generated catch block
        Connection conn = null;
        SQLContainer temp = null;
        SimpleJDBCConnectionPool serverconn= server.getConnection();
        System.out.println("serverobject handled");
        this.sqlquery = "SELECT * FROM " + table;
        System.out.println("Inside createMySQLContainer");
        conn = serverconn.reserveConnection();
        Statement stmt = conn.createStatement();
        rs = stmt.executeQuery(sqlquery);
        while ( {
            String username = rs.getString("Username");
            String password = rs.getString("Passwort");
            int id = rs.getInt("UserID");
            boolean admin = rs.getBoolean("Admin");
            System.out.println("Username: " + username +
                               " Password: " + password +
                               " ID: " + id +
                               " Admin: " + admin);
        return temp;

protected void init(VaadinRequest request){

    private void executeTest(){
        try {
        } catch (Exception e) {
            // TODO Auto-generated catch block

Its seems like the first Chunk of Code (ConnectToServer) is working properly, but the application always skips when breaks when using "conn = serverconn.reserveConnection()
and gives out a SQLNonTransientConnectionException, caused by an NullPointerException.

This gets me so confused ._.

I’m looking forward to any help on this topic but please dont suggest using JPA or SpringData, as i just started using Databases in Java i would like to
learn it from the beginning with an JDBC-Connection.

Thanks in advance!

Can you post the full stacktrace?

Hey Tom and thank you for your fast answer!

Tue Jun 21 17:35:39 CEST 2016 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
java.sql.SQLNonTransientConnectionException: Could not create connection to database server.
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(
    at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(
    at java.sql.DriverManager.getConnection(
    at java.sql.DriverManager.getConnection(
    at de.hsb.mystocklist.UserManagement.getUserTable(
    at de.hsb.mystocklist.MyUI.executeTest(
    at de.hsb.mystocklist.MyUI.init(
    at com.vaadin.ui.UI.doInit(
    at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(
    at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(
    at com.vaadin.server.SynchronizedRequestHandler.handleRequest(
    at com.vaadin.server.VaadinService.handleRequest(
    at com.vaadin.server.VaadinServlet.service(
    at javax.servlet.http.HttpServlet.service(
    at org.eclipse.jetty.servlet.ServletHolder.handle(
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(
    at org.eclipse.jetty.servlet.ServletHandler.doScope(
    at org.eclipse.jetty.server.session.SessionHandler.doScope(
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
    at org.eclipse.jetty.server.Server.handle(
    at org.eclipse.jetty.server.HttpChannel.handle(
    at org.eclipse.jetty.server.HttpConnection.onFillable(
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
    at org.eclipse.jetty.util.thread.QueuedThreadPool$
Caused by: java.lang.NullPointerException
    at java.util.Properties$LineReader.readLine(
    at java.util.Properties.load0(
    at java.util.Properties.load(
    at com.mysql.cj.jdbc.util.TimeUtil.loadTimeZoneMappings(
    at com.mysql.cj.jdbc.util.TimeUtil.getCanonicalTimezone(
    at com.mysql.cj.mysqla.MysqlaSession.configureTimezone(
    at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(
    at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(
    ... 39 more


thats what printStackTrace() produces… let me know if it helps you!

Could be a bug in the mysql driver:
Does the exception happen when you append ‘?useLegacyDatetimeCode=true’ to the connection URL (your DB_IP variable)?

just tried both, but had the same results as before.

when im using “com.mysql.jdbc.Driver” i get the Information that this is deprected and that “com.mysql.cj.jdbc.Driver” instead.
Could it be possible that it has something to do with the way i set up the project? I followed the vaadin-guide with maven and jetty as an webcontainer. Maybe its because the webcontainer doesn’t let me communicate from SimpleJDBCConnectionPool back to Database which is deployed on a webserver?

I also tried implementing a JDBC-Connection without Vaadin (only console). That Connection worked fine and i was able to execute all Statements (SELECT, UPDATE, INSERT,JOIN)?

I’m really starting to get clueless about whats causing the errors

That shouldn’t be an issue IMHO.
I’d try an older Connector/J release and see if it still happens (you might have to change JDBC_DRIVER = “com.mysql.cj.jdbc.Driver” to “com.mysql.jdbc.Driver” if you use one with version 5.x).