How to get all the column names from a ResultSet using JDBC.
Learning about a ResultSet using ResultSetMetaData methods. You cannot always know the number of columns and data types of the columns in a table or result set. This is true especially when you are retrieving data from a remote data source. About this task. When you write programs that retrieve unknown ResultSet s, you need to use ResultSetMetaData methods to determine the characteristics of.

Java ResultSetMetaData Interface. The metadata means data about data i.e. we can get further information from the data. If you have to get metadata of a table like total number of column, column name, column type etc., ResultSetMetaData interface is useful because it provides methods to get metadata from the ResultSet object.

Example of Fetching Result for the given rollno. Here, you will learn that how to fetch result for the given rollno. I am assuming that there is a table as given below: We are assuming there are many records in this table. In this example, we are getting the data from the database in servlet and printing it. We are doing all the database logic in servlet for simplicity of the program. But it.

String getColumnName(int columnNumber): Returns the name of the column whose index number is passed as parameter; int getColumnType(int columnNumber): Returns the name of the column as an integer value whose index number is passed as parameter. For example, 3 indicates DECIMAL and 12 indicates VARCHAR. 12 is represented as java.sql.Types.VARCHAR.

The general form of a result set is a table with column headings and the corresponding values returned by a query. For example, if your query is SELECT a, b, c FROM Table1, your result set will have the following form: a b c ----- ----- ----- 12345 Cupertino 2459723.495 83472 Redmond 1.0 83492 Boston 35069473.43 The following code fragment is an example of executing an SQL statement that will.

Table 2. ResultSetMetaData.getColumnName and ResultSetMetaData.getColumnName before and after IBM Data Server Driver for JDBC and SQLJ Version 4.0 for a table column with a LABEL ON statement in a query with an AS CLAUSE; Target data source Behavior before IBM Data Server Driver for JDBC and SQLJ Version 4.0 Behavior for IBM Data Server Driver for JDBC and SQLJ Version 4.0 and later.

When sparse column values are inserted or updated by using the XML column set, the values that are inserted into the underlying sparse columns are implicitly converted from the xml data type. In the case of numeric columns, a blank value in the XML for the numeric column converts to an empty string. This causes a zero to be inserted into the numeric column as shown in the following example.