MySQL Forums :: Utilities :: Fabric creates multiple DB connections


Advanced Search

Fabric creates multiple DB connections
Posted by: Puneet Nahata ()
Date: August 30, 2016 12:20PM

I have setup of 1 global group, 3 HA groups and 1 fabric node

The below piece of code ends up creating thousands of physical DB connections. The code errors out once all the max connection on DB is reached. According to my understanding, 1 fabric connection will contain map of single database connections to each physical DB servers.
Then why is below code trying to create thousands of physical connection on my HA1 server?

The range grouping is setup as 1-33000 to HA1, 33001-66000 to HA2 and 66001 onwards to HA3

Connection rawConnection = DriverManager.getConnection("jdbc:mysql:fabric://<fabricServer>:<port>/employees?fabricUsername=<fabricUser>&fabricPassword=<fabricPassword>&fabricShardTable=employees.employees", "<db_user>", "<db_password>");

FabricMySQLConnection fabricConnection = (FabricMySQLConnection) rawConnection;

for(int emp_id=1; emp_id<100000; emp_id++) {
fabricConnection.setShardKey(emp_id);
PreparedStatement ps = fabricConnection.prepareStatement(INSERT_EMPLOYEE_SQL);
ps.setInt(1, emp_id);
ps.setString(2, "Name"+i);
ps.setString(3, "Surname"+i);
ps.executeUpdate();
ps.close();
ps == null;
}


PS: i am using PreparedStatement inside the loop and not outside because i want to simulate real world scenareo where multipl user requests will run in parallel and they will create their own PreparedStatements

Options: ReplyQuote


Subject Views Written By Posted
Fabric creates multiple DB connections 675 Puneet Nahata 08/30/2016 12:20PM
Re: Fabric creates multiple DB connections 272 Puneet Nahata 08/30/2016 12:33PM
Re: Fabric creates multiple DB connections 272 Puneet Nahata 08/30/2016 02:33PM
Re: Fabric creates multiple DB connections 253 Jernej Krmelj 08/31/2016 06:54AM
Re: Fabric creates multiple DB connections 252 Puneet Nahata 08/31/2016 01:44PM
Re: Fabric creates multiple DB connections 240 Jernej Krmelj 09/01/2016 01:48AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.