File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and the fly likes Problem in writing file to db2 database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem in writing file to db2 database" Watch "Problem in writing file to db2 database" New topic

Problem in writing file to db2 database

Shan Accent

Joined: May 08, 2005
Posts: 23

I created the table to insert a clob data as follows
db2 => create table ctest(datas clob(65536))
DB20000I The SQL command completed successfully.
db2 => describe table ctest

Column Type Type
name schema name Length Scale Nulls

------------------------------ --------- ------------------ -------- ----- -----

1 record(s) selected.


I tried the following java code to insert a clob data.

public static synchronized Connection getConnection() throws Exception {

Connection m_connectionDatabase = null;
try {

// Get the connection to the database.
m_connectionDatabase = DriverManager.getConnection(
"jdbc b2:aps","","");
}catch (Exception e) {
throw new Exception("Failed to connect to the database. ", e);

return m_connectionDatabase;

public static void main(String a[]) {

File file = new File("d:\\a.txt");
InputStream fis = new FileInputStream(file);
Connection con = getConnection();
PreparedStatement pstmt = con.prepareStatement("insert into ctest values(?)");

//try 1

// try 2

// try 3

// try 4
byte[] b = new byte[fis.available()];;
pstmt.setBytes(1, b);

// try 5
byte[] b = new byte[fis.available()];;
pstmt.setString(1, new String(b));



If the file size is less than 32kb, it inserted successfully.

but if more than 32kb, it throws follwing exception [IBM][CLI Driver][DB2/NT] SQL0352N An unsupported SQLTYPE was encountered in position "1" of the input list (SQLDA). SQLSTATE=56084

at Source)
at Source)
at Source)
at Source)
at Source)
at Source)

Can any body please help out to insert clob value.

Thanks in advance
jQuery in Action, 2nd edition
subject: Problem in writing file to db2 database
Similar Threads
How to read/write text file to db2 by using java code
how to store/retrive image in oracle database using struts 1.2
image storing and retriving
Error while Inserting large string into Clob column
ORA-01461: can bind a LONG value only for insert into a LONG column