Subject | Re: java 1.5: Slow connection to Database |
---|---|
Author | nagypapi |
Post date | 2005-06-17T13:51:42Z |
Eventually if you have the IP address for the target machine (in my
case on the local network) using InetAddress.getByAddress() works as
expected
code I use to connect if I have the ip in a String:
byte[] raw_address=new byte[4];
String[] addressbits=ip.split("\\.");
for(int i=0;i<4;i++)
raw_address[i]=(byte)Integer.parseInt(addressbits[i]);
s=new Socket(InetAddress.getByAddress(ip,raw_address),port);
case on the local network) using InetAddress.getByAddress() works as
expected
code I use to connect if I have the ip in a String:
byte[] raw_address=new byte[4];
String[] addressbits=ip.split("\\.");
for(int i=0;i<4;i++)
raw_address[i]=(byte)Integer.parseInt(addressbits[i]);
s=new Socket(InetAddress.getByAddress(ip,raw_address),port);
--- In Firebird-Java@yahoogroups.com, "nagypapi" <nagypapi@f...> wrote:
> I haven't tried the patch for jaybird, but I tried
> InetAddress.getByName() in my own new Socket() code, and it didn't
help.
> I'll take a look at what workaround does work for me
> John
>
> --- In Firebird-Java@yahoogroups.com, Steven Jardine <steve@m...> wrote:
> >
> > >Because of this bug:
> > >http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5092063
> > >
> > >the 1.5 release of java runtime takes 4-5 seconds to connect to the
> > >database.
> > >I am looking for a workaround in java (not editing the hosts file or
> > >something else), that can be compiled under 1.4 and doesn't have this
> > >waiting problem if run under 1.5
> > >
> > >
> > It looks like changing the socket constructor to: new
> > Socket(InetAddress.getByName(dbai.getServer()), dbai.getPort());
should
> > fix the problem. The InetAddress.getByName call disables any reverse
> > DNS lookup.
> >
> > Would you let me know if this fixes the problem? I couldn't
reproduce
> > the problem on my machine.
> >
> > Steve