I'm not sure what your exact problem is, http://www.h2database.com/html/features.html#in_memory_databases says the correct syntax for an in-memory database that is accessible via tcp-ip is something like:
jdbc:h2:tcp://localhost:9092/mem:tcpTest;... not jdbc:h2:mem:tcp://localhost:9092/tcpTest;... .. which looks like it could be significant. Cheers Kerry <http://www.h2database.com/html/features.html#in_memory_databases> On Wed, May 26, 2010 at 4:05 AM, AGupta <[email protected]> wrote: > Hi, > > I am trying a simple example using the H2 in memory database. > > Experiment: Want to create an in memory Database and see the contents > of this in-mem database using a browser. > > Tried Solution: Used Spring to create the DBCP Pool for H2 db. Here is > the spring config. > > SPRING CONFIG: > <bean id="h2Server" class="org.h2.tools.Server" scope="singleton" > factory-method="createTcpServer" init-method="start" > destroy-method="stop"> > <constructor-arg > value="-tcp,-tcpAllowOthers,true,-tcpPort,9092" /> > </bean> > > <bean id="h2TCPDataSource" > class="org.apache.commons.dbcp.BasicDataSource" > destroy-method="close" depends-on="h2Server"> > <property name="driverClassName" value="org.h2.Driver" /> > <property name="url" > value="jdbc:h2:mem:tcp://localhost:9092/ > tcpTest;MODE=Oracle;DB_CLOSE_DELAY=-1;AUTO_SERVER=TRUE" /> > <property name="username" value="sa" /> > <property name="password" value="" /> > </bean> > > > JAVA CODE: > public static void main(String[] args) throws SQLException { > AbstractApplicationContext ctx = new > ClassPathXmlApplicationContext("spring/spring-h2-database.xml"); > > DataSource h2ds = (DataSource) > ctx.getBean("h2TCPDataSource"); > Connection conn = h2ds.getConnection(); > conn.createStatement().execute("create table MYTABLE (id > INTEGER, > name varchar(20), salary number)"); > conn.createStatement().execute("insert into MYTABLE > values(1,'AMIT', > 20000000.0)"); > > System.out.println("Row Inserted. Check on Console"); > } > > When opening a JS enabled Browser with URL (http://localhost:9092/): > > OUTPUT: > (AbstractStringBuilder.java:45) at java.lang.StringBuilder. > (StringBuilder.java:80) at > org.h2.value.Transfer.readString(Transfer.java:240) at > org.h2.server.TcpServerThread.run(TcpServerThread.java:78) ... 1 more > > I know I am doing something wrong but what? > > Thanks, > Amit-G. > > -- > You received this message because you are subscribed to the Google Groups > "H2 Database" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<h2-database%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/h2-database?hl=en. > > -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
