Currently i developing a java web application which uses Oracle 11g database. During connecting application with database i had some network issue due to IP protocol versions. The database i was using are of IPv4 protocol and application as of IPv6.
To fix this issue i changed the protocol of the application by adding an argument to my tomcat server.
-Djava.net.preferIPv4Stack=true
Yesterday while i was connecting my application to Amazon S3 , i faced the similar issue where Amazon S3 uses IPv6 protocol and currently application uses IPv4 protocol.
Code to connect DB:
@Bean
public DriverManagerDataSource dataSource() throws IOException {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
Credentials credentials = *****;
dataSource.setDriverClassName(driver);
dataSource.setUrl(credentials.getUrl());
dataSource.setUsername(credentials.getUsername());
dataSource.setPassword(credentials.getPassword());
return dataSource;
}
Is there any way to fix this issue , programmatically or changing the configuration in tomcat server so that i can able to use both database and AWS of different protocols ?