Win a copy of Java Challengers this week in the Java in General forum!

Mythily Mr

Greenhorn
+ Follow
since Jul 19, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mythily Mr

Hello friends,

I need to insert an image into the oracle db using jdbc.
I'm extracting the image from access db first as getBinaryStream and then inserting the same into oracle Blob data type column.

In access the image is stored in a column with data type OLE Object.

When i did this am geeting an error like

Io exception: InputStream is no longer valid - the Statement has been closed, or the cursor has been moved

Here is the code(for extracting data from Access Db)
public ArrayList<ArrayList<Member>> vSelectAll(ArrayList<String> tablename)
{
ArrayList<ArrayList<Member>> temp = new ArrayList<ArrayList<Member>>();
String temp_tablename =null;
Iterator it = tablename.iterator();
while(it.hasNext())
{
temp_tablename = (String)it.next();
System.out.println("tablename - "+temp_tablename);


String sql = "select * from "+temp_tablename;
try{
rs = st.executeQuery(sql);
while(rs.next())
{
product = rs.getString("PRODUCT");
Integer uwyear1 = rs.getInt("POLYEAR");
uwyear = uwyear1.toString();
memberno = rs.getString("MEMNO");
polserno = rs.getString("POLSRL");
Integer memsince1 = rs.getInt("MEMSINCE");
memsince = memsince1.toString();
picture = rs.getBinaryStream("PICTURE");

MemberDet.add(new Member(product,uwyear,memberno,polserno,memsince,picture));
}
System.out.println("MemberDet - "+MemberDet.size());
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}
temp.add(MemberDet);
}
return temp;
}
Here is the code:(for inserting to the oracle db)


public void vInsertPhoto(String product,String memberno,String polserno,String memsince,InputStream picture)
{
PreparedStatement st1 = null;
String sql = "insert into APP_MEMBER_PHOTO_DETAILS (AMP_PRODUCT_CODE,AMP_MEMBER_NO,AMP_MEM_REFERENCE_NO,AMP_MEMBER_PHOTO) values(?,?,?,?)";

try{
st1 = con.prepareStatement(sql);
if(picture !=null)
{
st1.setString(1, product);
st1.setString(2, memberno);
st1.setString(3, polserno);
st1.setBinaryStream(4, picture,1);
st1.setString(5, memsince);
st1.executeUpdate();
System.out.println("Insertion is happened");
}
else
System.out.println("picture is null");
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}
finally
{
try {

st1.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

Please help me out to solve this problem
9 years ago
Hi Friends,

I'm also facing the same problem.

When I try to insert a blob data of size 3kb its inserting fine.
But when the size increase to just 7 kb its giving error that

ORA-01460: unimplemented or unreasonable conversion requested

String sql = "insert into table_name(column1column2,column3,column4,column5) values(?,?,?,?,?)";

PreparedStatement stmt;
try {
stmt = con.prepareStatement(sql);

stmt.setString(1, "test1");
stmt.setString(2, "test2");
stmt.setString(3, "test3");

File image = new File("D:\\test.bmp");//file size is 128kb
FileInputStream fis = new FileInputStream(image);
stmt.setBinaryStream(4, fis, (int) image.length());
stmt.setString(5, "test5");
stmt.executeUpdate();

System.out.println("inserted the text file");

fis.close();

} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
9 years ago
Thanks for the replay..

I tried that but with that also there is no change

Actually I'm able to retrieve some of the varchar column data correctly.

But only for the columns which are having varchar(1400) datatype getting this error.

But in that for one column I'm able to retrieve some values but after some rows I'm getting the same error.

Help me to solve this problem
Hello Friends,

We have progress database 9.1B installed on the server.
i'm connecting to the progress database server from java jdbc connection.
I'm able to connect to the database and able to retrieve some of the data, But for some columns its giving error that

[JDBC Progress Driver]:Column FrnDetails in table PUB.GENCOND has value exceeding its max length or precision.

I checked in the database the variable datatype is varchar(1400) and the value in the field is not more than 700

I undestand that it is the normal problem in the progress database. But unable to find the solution.

Here is the code for connecting to the Progress database to retrieve the data from the database: