简体   繁体   中英

Incomplete ResultSet on Amazon EC2

I am running a JNDI JDBC connection pool on Tomcat hosted on an Amazon Web Services EC2 talking to an Amazon Web Services PostgreSQL Relational Database.

I have a table with 40,000 rows of data that I am attempting to collect in one go using a JDBC PreparedStatement "SELECT * FROM tableName".

This combination of things works flawlessly, collecting all 40,000 rows, when I run the servlet on my local machine (from my local Tomcat) and have it talk to the RDS via db-name.aws-rds-URL :5432, however, when I run the same servlet on my AWS EC2 and instruct it to talk to the RDS on its local vLAN, it never gets more than 30,000 rows, with resultSets as few as 2,000 rows. Each time I refresh it, it yields a new and different, yet incomplete, number of rows.

Below is my entry in Tomcat's global context.xml (I am using the same dataSource across multiple servlets).

< Resource
name="jdbc/postgres4"
auth="Container"
type="javax.sql.DataSource"
maxActive="8"
maxIdle="8"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://dn-name.aws-rds-URL:5432/SID"
username="db-username"
password="password" /> 

Any ideas on what could be going astray here?

This was not a database issue at all... I added a counter to the while(rs.next()) loop and I ended up with 40,000 every time, while the servlet row nums varied as before.

I managed to fix the issue by switching from the Google Guava MapMaker() ConcurrentMap to the Java ConcurrentHashMap, except now I have to deal with the Java HashMap GC memory issue again...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM