Hi
I have a List<String> tableNames;
I wanted to
In particular IBM DB2 UDB has some isssue where you can't retrive the metadata if table doesn't have any rows. For now we are using something likeCode:for(String tableName :tableNames) { //Here I wanted to get table meata data (ie, column names and types) //using jdbcTemplate }
If result set is null we are inserting dummy data and retrieving metadata using simple jdbc like below:Code:select * from table_name fetch first 1 row only
Is there anyway I can use jdbcTemplate to avoid all above bolierplate code?Code:ResultSet rs = stmt1.executeQuery("select * from "+tableName+" fetch first 1 rows only with ur") ; if(rs == null) { //build a statment like insert into schema_a.Tablename select * from schema_b.TableName }
I dont want to insert any dummy data.
Here in my case jdbcTemplate is built in runtime based on what environment user selected and we are using weblogic data sources, SchemaawareProxy to set schema.
I can write something like
But here I have a risk always "what if other schema doesn't have data?"Code:MyCustomObj obj= jdbcTemplate.queryForObject(sql, new MyRowMapperImpl()) if(obj == null) { jdbcTemplate.update(insert into schema_a.Tablename select * from schema_b.TableName fetch first 1 row only"); } //Then again get resultset or directly get metadata from other schema.
I have read this threadBut In my case I am dealing with DB2 UDB 9.5.HTML Code:http://forum.springsource.org/showthread.php?t=10812
Please help!


Reply With Quote
