vinodpanicker / h2database

Automatically exported from code.google.com/p/h2database
0 stars 0 forks source link

Error while getting connection from pool (when trying upgrade from 1.1 version to 1.2 version) #257

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I followed all instruction for upgrading the h2 version, putting migration jar 
but  while getting connection from pool i am getting null exception.

I m using JdbcConnectionPool for pooled connection.

Kindly share thoughts.

Nimish

Original issue reported on code.google.com by chaudhary.nimish@gmail.com on 24 Nov 2010 at 6:26

GoogleCodeExporter commented 9 years ago
> i am getting null exception.

That's too little information, sorry.

Original comment by thomas.t...@gmail.com on 24 Nov 2010 at 7:48

GoogleCodeExporter commented 9 years ago
hi Thomas,
            I am trying to upgrade h2 from 1.1.118 to Latest 1.2 h2 version.Changes i have made so far are:

1) Add h2mig_pagestore_addon.jar to class path
2) Change url from jdbc:h2.. to jdbc:h2v1_1...

Now,
i am trying to connect to H2 db with url= 
"jdbc:h2v1_1:tcp://localhost/C:\Program 
Files\test\oneXportal\Tomcat\apache-tomcat-6.0.18\bin\onexportal\midlayerdb;IGNO
RECASE=TRUE;" and  creating a connection pool with following code:

JdbcDataSource ds = new JdbcDataSource();
ds.setURL( url );
ds.setUser( "sa");
ds.setPassword( "");            
m_connectionPool = JdbcConnectionPool.create( ds );
m_connectionPool.setMaxConnections(50);

when i am trying to get connection from pool:

m_connectionPool.getConnection() i m getting Null exception.

Any thoughts?

Original comment by chaudhary.nimish@gmail.com on 24 Nov 2010 at 8:05

GoogleCodeExporter commented 9 years ago
> i m getting Null exception

What is the stack trace?

Original comment by thomas.t...@gmail.com on 24 Nov 2010 at 8:12

GoogleCodeExporter commented 9 years ago
java.lang.NullPointerException
        at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:131)
        at org.h2.jdbcx.JdbcXAConnection$PooledJdbcConnection.<init>(JdbcXAConnection.java:498)
        at org.h2.jdbcx.JdbcXAConnection.getConnection(JdbcXAConnection.java:131)
        at org.h2.jdbcx.JdbcConnectionPool.getConnectionNow(JdbcConnectionPool.java:224)
        at org.h2.jdbcx.JdbcConnectionPool.getConnection(JdbcConnectionPool.java:202)
        at org.h2.jdbcx.ConnectionPoolDecorator.getConnection(ConnectionPoolDecorator.java:27)
        at com.avaya.inkaba.dal.DBLayerImpl.createTables(DBLayerImpl.java:144)
        at com.avaya.inkaba.dal.DBLayerImpl.<init>(DBLayerImpl.java:81)
        at com.avaya.inkaba.dal.DataProvider.init(DataProvider.java:32)
        at com.avaya.inkaba.wssession.ApplicationSessionServicesImpl.init(ApplicationSessionServicesImpl.java:213)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at com.sun.xml.ws.server.AbstractInstanceResolver$1.run(AbstractInstanceResolver.java:171)
        at com.sun.xml.ws.server.AbstractInstanceResolver$1.run(AbstractInstanceResolver.java:166)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.xml.ws.server.AbstractInstanceResolver.invokeMethod(AbstractInstanceResolver.java:165)
        at com.sun.xml.ws.server.SingletonResolver.start(SingletonResolver.java:67)
        at com.sun.xml.ws.api.server.InstanceResolver$1.start(InstanceResolver.java:234)
        at com.sun.xml.ws.server.InvokerTube.setEndpoint(InvokerTube.java:80)
        at com.sun.xml.ws.server.WSEndpointImpl.<init>(WSEndpointImpl.java:163)
        at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:217)
        at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:467)
        at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(DeploymentDescriptorParser.java:253)
        at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:147)
        at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:108)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:830)
        at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:719)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
        at org.apache.catalina.core.StandardService.start(StandardService.java:516)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
java.lang.NullPointerException
        at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:131)
        at org.h2.jdbcx.JdbcXAConnection$PooledJdbcConnection.<init>(JdbcXAConnection.java:498)
        at org.h2.jdbcx.JdbcXAConnection.getConnection(JdbcXAConnection.java:131)
        at org.h2.jdbcx.JdbcConnectionPool.getConnectionNow(JdbcConnectionPool.java:224)
        at org.h2.jdbcx.JdbcConnectionPool.getConnection(JdbcConnectionPool.java:202)
        at org.h2.jdbcx.ConnectionPoolDecorator.getConnection(ConnectionPoolDecorator.java:27)
        at com.avaya.inkaba.dal.GlobalConfigurationTableImpl.search(GlobalConfigurationTableImpl.java:56)
        at com.avaya.inkaba.dal.GlobalConfigurationTableImpl.search(GlobalConfigurationTableImpl.java:40)
        at com.avaya.inkaba.dal.DBLayerImpl.isDatabaseVersionSupported(DBLayerImpl.java:1155)
        at com.avaya.inkaba.dal.DataProvider.init(DataProvider.java:33)
        at com.avaya.inkaba.wssession.ApplicationSessionServicesImpl.init(ApplicationSessionServicesImpl.java:213)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at com.sun.xml.ws.server.AbstractInstanceResolver$1.run(AbstractInstanceResolver.java:171)
        at com.sun.xml.ws.server.AbstractInstanceResolver$1.run(AbstractInstanceResolver.java:166)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.xml.ws.server.AbstractInstanceResolver.invokeMethod(AbstractInstanceResolver.java:165)
        at com.sun.xml.ws.server.SingletonResolver.start(SingletonResolver.java:67)
        at com.sun.xml.ws.api.server.InstanceResolver$1.start(InstanceResolver.java:234)
        at com.sun.xml.ws.server.InvokerTube.setEndpoint(InvokerTube.java:80)
        at com.sun.xml.ws.server.WSEndpointImpl.<init>(WSEndpointImpl.java:163)
        at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:217)
        at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:467)
        at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(DeploymentDescriptorParser.java:253)
        at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:147)
        at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:108)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:830)
        at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:719)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
        at org.apache.catalina.core.StandardService.start(StandardService.java:516)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Database version check failed. Database is unsupported

Original comment by chaudhary.nimish@gmail.com on 24 Nov 2010 at 8:22

GoogleCodeExporter commented 9 years ago
Hi,

Why do you use the url "jdbc:h2v1_1:..." and not just "jdbc:h2:..."?
Is that documented somewhere, if yes where?
Try with "jdbc:h2:...".

Regards,
Thomas

Original comment by thomas.t...@gmail.com on 26 Nov 2010 at 7:05

GoogleCodeExporter commented 9 years ago
Of course the NullPointerException is the wrong exception, I will fix this in 
the next release: "Connection pool / DataSource: a NullPointerException was 
thrown when using a database URL that doesn't start with "jdbc:h2:"."

Original comment by thomas.t...@gmail.com on 26 Nov 2010 at 7:07

GoogleCodeExporter commented 9 years ago
Hi Thomas,
I am working with Nimish on the DB upgrade\downgrade stuff and I had a couple 
of queries related to the same.
1. when upgrading (H2 DB created with v1.1.118 and then replacing the H2 jar 
with v1.2.147), do I need to change the URL? If not, then is it sufficient by 
just upgrading the H2 jar and using the pagestore addon jar?

2. when downgrading (H2 DB created with v1.2.147 and then replacing the H2 jar 
with v1.1.118), do I need to include the pagestore addon jar? Do I also need to 
change the URL as has been specified in the following link:
http://www.h2database.com/html/advanced.html#database_upgrade (last paragraph 
of 'database upgrade' section)

Original comment by adityagu...@gmail.com on 25 Jan 2011 at 12:54

GoogleCodeExporter commented 9 years ago
one more query along with the ones earlier:
3. My application creates two databases. When I migrate to the new H2 jar (and 
the pagestore addon jar), the backup of only one database is created whereas 
the other database continues to remain with the file format of old H2 database. 
What could be the reason for the same? Refer the attachment for details.

Original comment by adityagu...@gmail.com on 27 Jan 2011 at 1:43

Attachments:

GoogleCodeExporter commented 9 years ago
Sorry, I don't know what could be the reason. It's not logical that only one 
database is converted, if you use the exact same program in the same way for 
both databases. Therefore, I guess you either only open one database actually, 
or there is some difference in the database URL or classpath.

Original comment by thomas.t...@gmail.com on 29 Jan 2011 at 3:55

GoogleCodeExporter commented 9 years ago
could you also clarify about points 1 and 2 I have stated?

By the way, there is no change whatsoever in the creation of both the databases 
by the application.

Original comment by adityagu...@gmail.com on 3 Feb 2011 at 9:26

GoogleCodeExporter commented 9 years ago
Sorry, what should I clarify? I can't say why you changed the url from 
jdbc:h2.. to jdbc:h2v1_1, because I don't know that. Actually I asked you 
already why you did:

Why do you use the url "jdbc:h2v1_1:..." and not just "jdbc:h2:..."? Is that 
documented somewhere, if yes where? Try with "jdbc:h2:...".

Original comment by thomas.t...@gmail.com on 5 Feb 2011 at 10:50

GoogleCodeExporter commented 9 years ago
As mentioned in point 2 in my earlier comment, change of DB URL is mentioned in 
the following link:
http://www.h2database.com/html/advanced.html#database_upgrade (last paragraph 
of 'database upgrade' section). So I was wondering if changing the URL is 
relevant in case of downgrade?

By the way, when I changed the DB URL for the second database from actual path 
to relative path, it too got converted successfully in the newer format.

However, there was one more observation I wanted to highlight - Using the newer 
jar, I start the application. It creates both the databases in newer format. 
Now If I downgrade the H2 jar and use the older jar (v1.1.118) and restart the 
application, I lose all the data that the databases were having earlier. Is 
that the expected behavior?

Original comment by adityagu...@gmail.com on 7 Feb 2011 at 6:42

GoogleCodeExporter commented 9 years ago
Using the database URL "jdbc:h2v1_1:..." means the database is opened using the 
old driver. There is no upgrade done in this case. If you want to upgrade, use 
"jdbc:h2:...". I will try to better document this.

> in case of downgrade

To 'downgrade', you need to export the database to a SQL script file, and then 
create a new database using this script.

Original comment by thomas.t...@gmail.com on 9 Feb 2011 at 7:45

GoogleCodeExporter commented 9 years ago
There is one issue I have come across after I migrated from h2 version 1.1.118 
to 1.2.147. The jdbc resultset in 1.1.118 has a method 'getNString()' which we 
were using in  our application code. It seems that this method is no longer 
provided in the resultset object in the new H2 version 1.2.147.

Although we can change the code to use 'getString()' instead of 'getNString()', 
we are having issues with backward compatibility where older codebase has to be 
used along with new H2 jar.

any updates on why that method was unsupported and how getNString() method was 
different to getString() method in the older version, because there is no 
difference mentioned in the javadocs for these two methods?

Original comment by adityagu...@gmail.com on 6 May 2011 at 12:01

GoogleCodeExporter commented 9 years ago
getNString() is a JDBC 4.1 feature, but currently the driver is compiled for 
JDBC 4.0 by default. There is a switch to enable JDBC 4.1 features, but it's 
not enabled by default. The plan is to enable JDBC 4.1 in H2 version 1.4.x (see 
the roadmap). getNString() was enabled before, but this was unintended (because 
it's not a JDBC 4.0 feature).

Original comment by thomas.t...@gmail.com on 7 Jun 2011 at 5:53