@Test( expected = SQLException.class ) public void testGetNullConnection() throws SQLException { factory = new SimpleSQLReportDataFactory( mock( JndiConnectionProvider.class ) ); DataRow dataRow = mock( DataRow.class ); factory.getConnection( dataRow ); }
protected synchronized Connection getConnection( final DataRow dataRow ) throws SQLException { if ( connection == null ) { final String user; if ( userField == null ) { user = null; } else { final Object userRaw = dataRow.get( userField ); if ( userRaw instanceof String ) { user = String.valueOf( userRaw ); } else { user = null; } } final String password; if ( passwordField == null ) { password = null; } else { final Object passwordField = dataRow.get( this.passwordField ); if ( passwordField instanceof String ) { password = String.valueOf( passwordField ); } else { password = null; } } connection = connectionProvider.createConnection( user, password ); } if ( connection == null ) { throw new SQLException( "Unable to get a connection from the Connection-Provider." ); } return connection; }
SimpleSQLReportDataFactory extends AbstractDataFactory { protected synchronized Connection getConnection( final DataRow dataRow ) throws SQLException { if ( connection == null ) { final String user; if ( userField == null ) { user = null; } else { final Object userRaw = dataRow.get( userField ); if ( userRaw instanceof String ) { user = String.valueOf( userRaw ); } else { user = null; } } final String password; if ( passwordField == null ) { password = null; } else { final Object passwordField = dataRow.get( this.passwordField ); if ( passwordField instanceof String ) { password = String.valueOf( passwordField ); } else { password = null; } } connection = connectionProvider.createConnection( user, password ); } if ( connection == null ) { throw new SQLException( "Unable to get a connection from the Connection-Provider." ); } return connection; } }
SimpleSQLReportDataFactory extends AbstractDataFactory { protected synchronized Connection getConnection( final DataRow dataRow ) throws SQLException { if ( connection == null ) { final String user; if ( userField == null ) { user = null; } else { final Object userRaw = dataRow.get( userField ); if ( userRaw instanceof String ) { user = String.valueOf( userRaw ); } else { user = null; } } final String password; if ( passwordField == null ) { password = null; } else { final Object passwordField = dataRow.get( this.passwordField ); if ( passwordField instanceof String ) { password = String.valueOf( passwordField ); } else { password = null; } } connection = connectionProvider.createConnection( user, password ); } if ( connection == null ) { throw new SQLException( "Unable to get a connection from the Connection-Provider." ); } return connection; } SimpleSQLReportDataFactory();  SimpleSQLReportDataFactory( final Connection connection );  SimpleSQLReportDataFactory( final ConnectionProvider connectionProvider ); }
SimpleSQLReportDataFactory extends AbstractDataFactory { protected synchronized Connection getConnection( final DataRow dataRow ) throws SQLException { if ( connection == null ) { final String user; if ( userField == null ) { user = null; } else { final Object userRaw = dataRow.get( userField ); if ( userRaw instanceof String ) { user = String.valueOf( userRaw ); } else { user = null; } } final String password; if ( passwordField == null ) { password = null; } else { final Object passwordField = dataRow.get( this.passwordField ); if ( passwordField instanceof String ) { password = String.valueOf( passwordField ); } else { password = null; } } connection = connectionProvider.createConnection( user, password ); } if ( connection == null ) { throw new SQLException( "Unable to get a connection from the Connection-Provider." ); } return connection; } SimpleSQLReportDataFactory();  SimpleSQLReportDataFactory( final Connection connection );  SimpleSQLReportDataFactory( final ConnectionProvider connectionProvider ); String getUserField(); void setUserField( final String userField ); String getPasswordField(); void setPasswordField( final String passwordField ); int getBestResultSetType( final DataRow dataRow ); synchronized TableModel queryData( final String query, final DataRow parameters ); String[] getReferencedFields( final String query, final DataRow parameters ); static boolean isExpandArrayParameterNeeded( final String query ); ResultSet performQuery( Statement statement, final String translatedQuery, final String[] preparedParameterNames ); void cancelRunningQuery(); synchronized void close(); SimpleSQLReportDataFactory clone(); void setConnectionProvider( final ConnectionProvider connectionProvider ); ConnectionProvider getConnectionProvider(); boolean isQueryExecutable( final String query, final DataRow parameters ); String[] getQueryNames(); ArrayList<Object> getQueryHash( final String queryName, final DataRow parameter ); }
SimpleSQLReportDataFactory extends AbstractDataFactory { protected synchronized Connection getConnection( final DataRow dataRow ) throws SQLException { if ( connection == null ) { final String user; if ( userField == null ) { user = null; } else { final Object userRaw = dataRow.get( userField ); if ( userRaw instanceof String ) { user = String.valueOf( userRaw ); } else { user = null; } } final String password; if ( passwordField == null ) { password = null; } else { final Object passwordField = dataRow.get( this.passwordField ); if ( passwordField instanceof String ) { password = String.valueOf( passwordField ); } else { password = null; } } connection = connectionProvider.createConnection( user, password ); } if ( connection == null ) { throw new SQLException( "Unable to get a connection from the Connection-Provider." ); } return connection; } SimpleSQLReportDataFactory();  SimpleSQLReportDataFactory( final Connection connection );  SimpleSQLReportDataFactory( final ConnectionProvider connectionProvider ); String getUserField(); void setUserField( final String userField ); String getPasswordField(); void setPasswordField( final String passwordField ); int getBestResultSetType( final DataRow dataRow ); synchronized TableModel queryData( final String query, final DataRow parameters ); String[] getReferencedFields( final String query, final DataRow parameters ); static boolean isExpandArrayParameterNeeded( final String query ); ResultSet performQuery( Statement statement, final String translatedQuery, final String[] preparedParameterNames ); void cancelRunningQuery(); synchronized void close(); SimpleSQLReportDataFactory clone(); void setConnectionProvider( final ConnectionProvider connectionProvider ); ConnectionProvider getConnectionProvider(); boolean isQueryExecutable( final String query, final DataRow parameters ); String[] getQueryNames(); ArrayList<Object> getQueryHash( final String queryName, final DataRow parameter ); static Configuration globalConfig; }