1

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 ?

Joby Wilson Mathews
  • 10,528
  • 6
  • 54
  • 53
  • "I had some network issue"... would you care elaborating on "some"? Please provide an [MCVE](https://stackoverflow.com/help/mcve) – Olaf Kock Mar 10 '18 at 09:31
  • @OlafKock [This](https://stackoverflow.com/questions/48185294/java-io-exception-the-network-adapter-could-not-establish-the-connection?noredirect=1#comment83350941_48185294) was the first issue that i had while connecting with db. After fixing it now i having issue with connecting with aws. Now i cannot able to use both db and aws at same time in my application. – Joby Wilson Mathews Mar 10 '18 at 09:48
  • ...and the error message that you get is...? – Olaf Kock Mar 10 '18 at 10:15
  • https://stackoverflow.com/questions/10378471/how-to-support-both-ipv4-ipv6-on-java – Ali Akbarpour Mar 10 '18 at 10:25

0 Answers0