Re: Pool error connecting to database
Mikel Lertxundi wrote:
> Hi,
>
> I've made an aplication that conects to a database
> via mysql Connector/J 3.1.8 version and
> I've this error when trying to connect to the
> Database:
>
> java.net.SocketException: java.net.BindException:
> Address already in use: connect
> at
> com.mysql.jdbc.StandardSocketFactory.connect(Stand
> ardSocketFactory.java:151)
> at
> com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:2
> 80)
> at
> com.mysql.jdbc.Connection.createNewIO(Connection.j
> ava:1774)
> at
> com.mysql.jdbc.Connection.<init>(Connection.
> java:437)
> at
> com.mysql.jdbc.NonRegisteringDriver.connect(NonReg
> isteringDriver.java:268)
> at
> java.sql.DriverManager.getConnection(DriverManager
> .java:512)
> at
> java.sql.DriverManager.getConnection(DriverManager
> .java:171)
> at
> controlmontaje.GestorBD.<init>(GestorBD.java
> :33)
> at
> controlmontaje.Montaje.ficheroPrepsTratado(Montaje
> .java:345)
> at
> controlmontaje.Principal.main(Principal.java:40)
>
> It's weird but I´ve got this error time after
> several inserts are made to the database via JAVA
> aplication.
>
> Thanks, and excuse my English I've got it a little
> bit rusty.
Hi Mikel,
Never mind, my English is worse :p
Then, that "BindException" occured in getConnection is unusual.
First of your stack trace, " StandardSocketFactory.connect(StandardSocketFactory.java:151) "
means this is simple Socket level error.
What can you see if you do "netstat" command to OS, when your error occured?
I could repeat the BindException by the following trivial sample code.
May be your application got Socket leak ? (forgetting socket.close() in somewhere?)
public static void main(String[] args) throws Exception {
String host = "localhost";
int port = 3306;
int count = 100000;
java.net.Socket socket = null;
int i = 0;
try {
while (i++ < count) {
socket = new java.net.Socket(host, port);
//socket.close();
}
} catch (java.net.BindException e) {
e.printStackTrace();
System.out.println(i);
}
System.out.println("done");
}
Cheers,
-- Tetsuro
Subject
Written By
Posted
Re: Pool error connecting to database
June 03, 2005 02:44AM
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.