Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE fix if url used like: jdbc:mariadb://localhost/testj?user=root&maxPoolSize=10 #126

Merged
merged 2 commits into from Jul 19, 2018

Conversation

rbhawsar
Copy link
Contributor

//Sample Program to create NullPointerException:

public class ConnectionUsingDS {
public static void main(String args[]) throws SQLException {
MariaDbPoolDataSource pool =
new MariaDbPoolDataSource("jdbc:mariadb://localhost/testj?user=root&maxPoolSize=10");
try (Connection conn = pool.getConnection()) {
try(Statement stmt = conn.createStatement()){
ResultSet rs = stmt.executeQuery("select 'Hello World!'");
while(rs.next()){
System.out.println(rs.getString(1));
}
System.out.println(pool.getDatabaseName() +", "+pool.getPort());
}
}

}

}
//Output:
//Hello World!
//Exception in thread "main" java.lang.NullPointerException
// at org.mariadb.jdbc.MariaDbPoolDataSource.getPort(MariaDbPoolDataSource.java:153)
// at mariadb.test.connection.ConnectionUsingDS.main(ConnectionUsingDS.java:32)

@rbhawsar
Copy link
Contributor Author

rbhawsar commented Jun 15, 2018

after the fix output of program changes to
Hello World!
testj, 3306

@rbhawsar
Copy link
Contributor Author

I am contributing all code of this whole pull request, including all affected files, under the BSD-new license.

@rbhawsar
Copy link
Contributor Author

travis job is failing with the error: Could not connect to HostAddress{host='null', port=3306, type='slave'}. null.

Can anyone help me on fixing the job and reviewing my PR.

@rusher
Copy link
Collaborator

rusher commented Jun 25, 2018

Hi @rbhawsar .

Thanks for this pull request. That will be merged in develop branch soon.

The error is not due to your PR. It seems hidden environment variable from Travis does not apply to PR anymore. I need to check that then and confirm it and changed tests accordingly if it's the case.

Diego

@rbhawsar
Copy link
Contributor Author

Hi @rusher,
thank you, really appreciate it.

Best,
Rahul

@rusher
Copy link
Collaborator

rusher commented Jul 6, 2018

Right, just for your information, the reason pull request test doesn't work anymore : https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions

I'll merge PR's today ( and correct test so they work even if not having the Travis secure environment variables)

@rusher
Copy link
Collaborator

rusher commented Jul 6, 2018

merge into develop branch (will be on next correction release)

@rusher rusher merged commit b24e66b into mariadb-corporation:master Jul 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants