RE: Derby as an in-memory JEE datasource

2010-01-08 Thread Marcin Kwapisz
I think that sub-protocol memory is ignored. When I start Derby as a normal 
db server, connection can be established (with that connection pool) and 
everything works fine. Maybe I do something wrong. I do not know, so I asked if 
it is possible to configure in-memory database as a datasource.

This is my connection pool configuration:

jdbc-connection-pool allow-non-component-callers=false 
associate-with-thread=false connection-creation-retry-attempts=0 
connection-creation-retry-interval-in-seconds=10 
connection-leak-reclaim=false connection-leak-timeout-in-seconds=0 
connection-validation-method=auto-commit 
datasource-classname=org.apache.derby.jdbc.ClientDataSource 
fail-all-connections=false idle-timeout-in-seconds=300 
is-connection-validation-required=false is-isolation-level-guaranteed=true 
lazy-connection-association=false lazy-connection-enlistment=false 
match-connections=false max-connection-usage-count=0 max-pool-size=32 
max-wait-time-in-millis=6 name=TestDBPoolMem 
non-transactional-connections=false pool-resize-quantity=2 
res-type=javax.sql.DataSource statement-timeout-in-seconds=-1 
steady-pool-size=8 validate-atmost-once-period-in-seconds=0 
wrap-jdbc-objects=false
property name=serverName value=localhost/
property name=PortNumber value=1527/
property name=networkProtocol value=jdbc:derby:memory/
property name=DatabaseName value=EntityTestDB/
property name=User value=testdb/
property name=Password value=testdb/
/jdbc-connection-pool

The error I got:
INFO: EclipseLink, version: Eclipse Persistence Services - 2.0.0.v20091127-r5931
2010-01-08 09:16:45 
com.sun.enterprise.resource.allocator.LocalTxConnectorAllocator createResource
WARNING: poolmgr.create_resource_error
2010-01-08 09:16:45 com.sun.enterprise.connectors.ConnectionManagerImpl 
internalGetConnection
WARNING: poolmgr.get_connection_failure
2010-01-08 09:16:45 com.sun.gjc.spi.base.DataSource getConnection
WARNING: jdbc.exc_get_conn
2010-01-08 09:16:45 org.eclipse.persistence.session.file: _InitPU.ejb
SEVERE: 
Local Exception Stack: 
Exception [EclipseLink-4002] (Eclipse Persistence Services - 
2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. 
Cause: Connection could not be allocated because: java.net.ConnectException: 
Błąd podczas łączenia z serwerem localhost na porcie 1527 z komunikatem 
Connection refused: connect.

Regards
Marcin Kwapisz



Re: Derby as an in-memory JEE datasource

2010-01-08 Thread Kristian Waagan

Marcin Kwapisz wrote:

I think that sub-protocol memory is ignored. When I start Derby as a normal 
db server, connection can be established (with that connection pool) and everything works 
fine. Maybe I do something wrong. I do not know, so I asked if it is possible to 
configure in-memory database as a datasource.

This is my connection pool configuration:

jdbc-connection-pool allow-non-component-callers=false associate-with-thread=false connection-creation-retry-attempts=0 connection-creation-retry-interval-in-seconds=10 connection-leak-reclaim=false connection-leak-timeout-in-seconds=0 
connection-validation-method=auto-commit datasource-classname=org.apache.derby.jdbc.ClientDataSource fail-all-connections=false idle-timeout-in-seconds=300 is-connection-validation-required=false is-isolation-level-guaranteed=true 
lazy-connection-association=false lazy-connection-enlistment=false match-connections=false max-connection-usage-count=0 max-pool-size=32 max-wait-time-in-millis=6 name=TestDBPoolMem non-transactional-connections=false 
pool-resize-quantity=2 res-type=javax.sql.DataSource statement-timeout-in-seconds=-1 steady-pool-size=8 validate-atmost-once-period-in-seconds=0 wrap-jdbc-objects=false
property name=serverName value=localhost/
property name=PortNumber value=1527/
property name=networkProtocol value=jdbc:derby:memory/
property name=DatabaseName value=EntityTestDB/
property name=User value=testdb/
property name=Password value=testdb/
/jdbc-connection-pool
  


Hi Marcin,

The network driver doesn't really support the memory subsubprotocol in a 
proper way, but you can try to either remove networkProtocol or set it 
to jdbc:derby if it is required  (not sure if it should end with a 
colon or not), and then specify memory:EntityTestDB as DatabaseName.


There is some other information at 
http://wiki.apache.org/db-derby/InMemoryBackEndPrimer , but note that 
the proper way to drop an in-memory database in the next 
feauture-release will be to use the JDBC connection attribute ;drop=true.



The error I got:
INFO: EclipseLink, version: Eclipse Persistence Services - 2.0.0.v20091127-r5931
2010-01-08 09:16:45 
com.sun.enterprise.resource.allocator.LocalTxConnectorAllocator createResource
WARNING: poolmgr.create_resource_error
2010-01-08 09:16:45 com.sun.enterprise.connectors.ConnectionManagerImpl 
internalGetConnection
WARNING: poolmgr.get_connection_failure
2010-01-08 09:16:45 com.sun.gjc.spi.base.DataSource getConnection
WARNING: jdbc.exc_get_conn
2010-01-08 09:16:45 org.eclipse.persistence.session.file: _InitPU.ejb
SEVERE: 
Local Exception Stack: 
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DatabaseException

Internal Exception: java.sql.SQLException: Error in allocating a connection. 
Cause: Connection could not be allocated because: java.net.ConnectException: 
Błąd podczas łączenia z serwerem localhost na porcie 1527 z komunikatem 
Connection refused: connect.
  


I'm not quite sure why you get this error, maybe it's because of the 
specified network protocol. Otherwise, make sure your Derby network 
server is up and running.



Hope this helps,
--
Kristian


Regards
Marcin Kwapisz

  





Re: Derby as an in-memory JEE datasource

2010-01-08 Thread Peter Ondruška
I tested connection pool with these properties:

DatabaseName=memory:Test;create=true
User=APP
SecurityMechanism=4
RetrieveMessageText=true
Password=APP
TraceFileAppend=false
TraceLevel=-1
ServerName=localhost
PortNumber=1527
Ssl=off
LoginTimeout=0

Do not have any applications using database, but try yourself and let us know.

On Fri, Jan 8, 2010 at 9:44 AM, Kristian Waagan kristian.waa...@sun.com wrote:
 Marcin Kwapisz wrote:

 I think that sub-protocol memory is ignored. When I start Derby as a
 normal db server, connection can be established (with that connection pool)
 and everything works fine. Maybe I do something wrong. I do not know, so I
 asked if it is possible to configure in-memory database as a datasource.

 This is my connection pool configuration:

 jdbc-connection-pool allow-non-component-callers=false
 associate-with-thread=false connection-creation-retry-attempts=0
 connection-creation-retry-interval-in-seconds=10
 connection-leak-reclaim=false connection-leak-timeout-in-seconds=0
 connection-validation-method=auto-commit
 datasource-classname=org.apache.derby.jdbc.ClientDataSource
 fail-all-connections=false idle-timeout-in-seconds=300
 is-connection-validation-required=false
 is-isolation-level-guaranteed=true lazy-connection-association=false
 lazy-connection-enlistment=false match-connections=false
 max-connection-usage-count=0 max-pool-size=32
 max-wait-time-in-millis=6 name=TestDBPoolMem
 non-transactional-connections=false pool-resize-quantity=2
 res-type=javax.sql.DataSource statement-timeout-in-seconds=-1
 steady-pool-size=8 validate-atmost-once-period-in-seconds=0
 wrap-jdbc-objects=false
        property name=serverName value=localhost/
        property name=PortNumber value=1527/
        property name=networkProtocol value=jdbc:derby:memory/
        property name=DatabaseName value=EntityTestDB/
        property name=User value=testdb/
        property name=Password value=testdb/
    /jdbc-connection-pool


 Hi Marcin,

 The network driver doesn't really support the memory subsubprotocol in a
 proper way, but you can try to either remove networkProtocol or set it to
 jdbc:derby if it is required  (not sure if it should end with a colon or
 not), and then specify memory:EntityTestDB as DatabaseName.

 There is some other information at
 http://wiki.apache.org/db-derby/InMemoryBackEndPrimer , but note that the
 proper way to drop an in-memory database in the next feauture-release will
 be to use the JDBC connection attribute ;drop=true.

 The error I got:
 INFO: EclipseLink, version: Eclipse Persistence Services -
 2.0.0.v20091127-r5931
 2010-01-08 09:16:45
 com.sun.enterprise.resource.allocator.LocalTxConnectorAllocator
 createResource
 WARNING: poolmgr.create_resource_error
 2010-01-08 09:16:45 com.sun.enterprise.connectors.ConnectionManagerImpl
 internalGetConnection
 WARNING: poolmgr.get_connection_failure
 2010-01-08 09:16:45 com.sun.gjc.spi.base.DataSource getConnection
 WARNING: jdbc.exc_get_conn
 2010-01-08 09:16:45 org.eclipse.persistence.session.file: _InitPU.ejb
 SEVERE: Local Exception Stack: Exception [EclipseLink-4002] (Eclipse
 Persistence Services - 2.0.0.v20091127-r5931):
 org.eclipse.persistence.exceptions.DatabaseException
 Internal Exception: java.sql.SQLException: Error in allocating a
 connection. Cause: Connection could not be allocated because:
 java.net.ConnectException: Błąd podczas łączenia z serwerem localhost na
 porcie 1527 z komunikatem Connection refused: connect.


 I'm not quite sure why you get this error, maybe it's because of the
 specified network protocol. Otherwise, make sure your Derby network server
 is up and running.


 Hope this helps,
 --
 Kristian

 Regards
 Marcin Kwapisz







Starting embedded Derby Replication within Tomcat web application

2010-01-08 Thread Erick Lichtas
Hi all,

 

I have a web application using derby in embedded mode.  This application is
running on tomcat 6 web server.  I am trying to set up master/slave
replication to another derby database, also in embedded mode.  For this
setup, both databases are on the same host and the version of Derby that I
am using is 10.5.3.  Before starting the replication, I make sure the master
is completely shut down, and make a fresh copy to the slave location.

 

The problem I am having is that when I start the master database, I am
getting the error message 

ERROR XRE22: Replication master has already been booted for database
'C:\Dev\Derby Databases\test'

 

The slave seems to have accepted the connection as I get the exception with
state XRE08 (which according to the documentation means the slave accepted
the connection from the master)

 

Everything seems to be set up right.  If I start the replication with the
databases outside of the tomcat container, using some client like SQuirreL
SQL or MyEclipse DB explorer, I can get the replication working just fine.

 

When the web app starts, I am making the connection with
'startMaster=true;slavePort=' as the first thing in my context startup
listener.  I am starting it using a data source I have defined in tomcat's
server.xml

 

DataSource ds = null;

if (ds == null) {

  if (ds == null) {

Context context = new InitialContext();

ds = (DataSource) context.lookup(JNDI_NAME_START);

  }

}

ds.getConnection();

 

Upon making the call to ds.getConnection(), this is when the slave accepts
the connection and I get the exception with error XRE22 noted above.  Based
on the error message, it looks like the master has already been started for
some reason.

 

Any thoughts would be very much appreciated.

 

Thanks in advance,

 

 

Erick Lichtas

 

 http://www.linomasoftware.com/ Linoma-Software-Logo

1409 Silver Street, Ashland, NE 68003

1-800-949-4696 x714

 

image001.jpg