db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Björn Bachman <bjorn.bach...@ericsson.com>
Subject Re: SQLTransientConnectionException
Date Thu, 20 Nov 2008 06:35:29 GMT
Hi!

I must admit that I'm a bit confused.

During my reading of the Derby Documentation I get two impressions
 - Derby is in manin an embedded db that under certain conditions can act as
a server towards several processes.
http://db.apache.org/derby/docs/dev/adminguide/cadminov17524.html
 - Derby can act as a full network server handling requests from several
client processes at the same time
http://db.apache.org/derby/docs/dev/adminguide/cadminov65220.html 

Depending on the answer above I might have done wrong in my code.

My problem arise when I have 2 separate java processes working _intensivly_
with reads towards javaDB running as a network server, reading the same
table and tablespace.

I have set #threads to 50
I have not set timeslice

Code :
----- snip -----
	...
	String tablename = prop.getProperty("DB_TABLE")+ "://" + 
	String dbURL = prop.getProperty("DB_DRIVER")+ "://" + 
		prop.getProperty("DB_HOST") + ":" + 
		prop.getProperty("DB_PORT")+"/" + 
		prop.getProperty("DB_NAME"); 

	conn = DriverManager.getConnection(dbURL);

	// Create a Statement
	stmt = conn.createStatement ();
	String myQ = "SELECT * from "+tablename+" where NAME='"+name+"'"; 
	rset = stmt.executeQuery (myQ);
	while (rset.next ()){				// quite some
records for all processes
		retVal = new OwnDataType();
		retVal.a = rset.getString(1);
		retVal.b = rset.getString(2);
		retVal.c = rset.getString(3);
		retVal.c = rset.getString(4);
		final.put(retVal.a, retVal);
	}
	rset.close();    
	...

----- snip -----

I am not using any connection pooling

The problem happens at once, no delay.

Cleanup is performed. Had an Experience with Oracle when I "forgot" to close
connections. Server was needed to be reset quite often, so now I do ;-)


Stacktrace (I've obfuscated some names and ports for security reasons.)
----- snip -----
java.sql.SQLTransientConnectionException: java.net.BindException : Error
connecting to server xxx.ericsson.se on port xxxx with message Address
already in use: connect.
        at
org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown
Source)
        at org.apache.derby.client.am.SqlException.getSQLException(Unknown
Source)
        at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:207)
        at
se.ericsson.PIA.genericTypes.OwnDataType.getData(OwnDataType.java:241)
        at
se.ericsson.PIA.portal.OwnData_Importer.local_do_Import(OwnData_Importer.jav
a:385)
        at
se.ericsson.PIA.portal.OwnData_Importer.run(OwnData_Importer.java:112)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.apache.derby.client.am.DisconnectException:
java.net.BindException : Error connecting to server xxx.ericsson.se on port
xxxx with message Address already in use: connect.
        at org.apache.derby.client.net.NetAgent.<init>(Unknown Source)
        at org.apache.derby.client.net.NetConnection.newAgent_(Unknown
Source)
        at org.apache.derby.client.am.Connection.<init>(Unknown Source)
        at org.apache.derby.client.net.NetConnection.<init>(Unknown Source)
        at org.apache.derby.client.net.NetConnection40.<init>(Unknown
Source)
        at
org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40.newNetConnection(U
nknown Source)
        ... 7 more
Caused by: java.net.BindException: Address already in use: connect
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:519)
        at java.net.Socket.connect(Socket.java:469)
        at java.net.Socket.<init>(Socket.java:366)
        at java.net.Socket.<init>(Socket.java:180)
        at
javax.net.DefaultSocketFactory.createSocket(SocketFactory.java:196)
        at org.apache.derby.client.net.OpenSocketAction.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        ... 13 more
----- snip -----

Question is if I use derby correctly, loading it with thousands of
simultaneous read calls from several clients. 

Best regards
\Björn Bachman




Björn Bachman wrote:
>
> Hi!
>
> I have several java processes running on a server, collecting data 
> from several databases(on other servers), processing the data and then 
> storing it into different tables in a derby running network mode (same 
> machine).
>
> I'm using version 10.4.2 and nave set the number of threads to 50(as 
> god as any value).
>
> It seems like when 2 processes tries to access the derby server one of 
> them gets a SQLTransientConnectionException with reason connection 
> already in use.
>
> Is this a known problem (either to Derby or to code design) with a 
> known workaround or ...
>

Hello Björn,

This sounds like a bug to me, either in Derby or maybe in the 
application code.

o Can you post the exception stack trace?
o Have you specified any other properties for the network server, like 
time-slicing?
o How do you obtain connections in the application code?
o Are using some kind of connection pooling software?
o Does it happen at once, or do you suspect that it happens when the 50 
threads/connections have been "exhausted"?
o Are you cleaning up the resources in the application code? (i.e. 
closing result sets and connections)

Maybe answers to some of these questions can help make the problem clearer.


-- 
Kristian

> Best Reagards
> \Björn Bachman
>




Mime
View raw message