Spring batch RowMapper - get number of columns and type

In my batch job application, I am using

org.springframework.batch.item.database.JdbcCursorItemReader

The SQL query is not known at compile time.

I am having trouble with RowMapper interface and its

T mapRow(ResultSet rs, int rowNum) throws SQLException;

Having only the resultset I can't know the number of columns and type of each column.

What are my options?

Answers


You can call rs.getMetaData(). See http://docs.oracle.com/javase/7/docs/api/java/sql/ResultSet.html#getMetaData%28%29 and http://docs.oracle.com/javase/7/docs/api/java/sql/ResultSetMetaData.html


Need Your Help

How to submit form with data before logging someone out?

javascript forms submit

I'm using the document.form.submit() function for a rather large input form (hundreds of fields, it's an inventory application). I'm calling this after the user has been idle for a certain amount of

Unable to close OledbDataReader to Sybase Database in VB.NET

vb.net sybase data-access

I don't seem to be able to close the OledbDataReader object after reading data from it. Here is the relevant code -

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.