JDBC: Working with XML type in Oracle

Today, I had a task to change a column’s data type in oracle from varchar2 to xmltype and reflect the same in JDBC code. The version of oracle was 9.2.0. I considered this task to be an easy one as Java 6 added the support for XML data type which is SQLXML type. I changed the data type in JDBC code accordingly.

To my surprize it did not work.

After googling for few minutes I came to know that java-6 uses JDBC-4 and which is not supported by the version of oracle I was using. So I had to resort to the solution used for this prior to Java-6. I found the following link very helpful for the using xml type data with the help of JDBC:


Enjoy learning,


Common mistake in JDBC programming

JDBC is something every java developer often encounters in his day to day life. I really admire people who never forget to close a connection. But many of us are careful enough to close the resultset, statement as well as connection in the finally block, somewhat like below:


. . . ;


if(rs!=null) rs.close();

if(stmt!=null) stmt.close();

if(conn!=null) conn.close();


Do you think there is really a need of doing all this? The answer is no.

When you close a statement, the associated result set is automatically closed. Similarly if you close the connection, all statements of that connection are automatically closed.

So there is no need to close all the three, result set, statement and connection.

Enjoy Learning