Skip to content

Commit

Permalink
Update how MySQLAccess passes user+password to get Connection.
Browse files Browse the repository at this point in the history
  • Loading branch information
randykerber authored and egonw committed May 9, 2017
1 parent df25e19 commit 3570573
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions org.bridgedb.sql/src/org/bridgedb/mysql/MySQLAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

/**
* MYSQL specific wrapper.
*
*
* @author Christian
*/
public class MySQLAccess implements SQLAccess{
Expand All @@ -37,10 +37,10 @@ public class MySQLAccess implements SQLAccess{
private String username;// = "irs";
/** password for the database */
private String password;// = "irs";

/**
* Instantiate a connection to the database
*
*
* @throws IMSException If there is a problem connecting to the database.
*/
public MySQLAccess(String dbUrl, String username, String password) throws BridgeDBException {
Expand All @@ -65,14 +65,20 @@ public MySQLAccess(String dbUrl, String username, String password) throws Bridge

/**
* Retrieve an active connection to the database
*
*
* @return database connection
* @throws IMSException if there is a problem establishing a connection
*/
@Override
public Connection getConnection() throws BridgeDBException {
try {
Connection conn = DriverManager.getConnection(dbUrl, username, password);
java.util.Properties info = new java.util.Properties();

info.put("user", username);
info.put("password", password);
info.put("protocol", "tcp");

Connection conn = DriverManager.getConnection(dbUrl, info);
return conn;
} catch (SQLException ex) {
System.err.println(ex);
Expand All @@ -81,5 +87,5 @@ public Connection getConnection() throws BridgeDBException {
throw new BridgeDBException(msg, ex);
}
}

}

0 comments on commit 3570573

Please sign in to comment.