Putting data to database?HELP

Hello, can anybody help me. I'm trying to store a blob object in to SQL Server 2000 and i got java.lang.ArrayIndexOutOfBoundsException

on the line pstm.setBinaryStream(7,infile,infile.available());

THANKS !!!!

This is mainly my source:

Connection con = null;

PreparedStatement pstm = null;

try

{

Date dtDate = Date.valueOf(strDate);

con = getConnection();

con.setAutoCommit(false);

Blob blob = null;

pstm = con.prepareStatement("INSERT INTO Version(Id_Number, Description, Version_Size, Version_Number, Marked, Create_Date, The_File, File_Record_Number)values ('?','?','?',?,?,?,?,?)");

System.out.println("essi f na setning komin ofninn");

java.io.File file = new java.io.File("c:\\tmp\\files\\filein.doc");

FileInputStream infile = new FileInputStream (file);

pstm.setBinaryStream(7, infile,infile.available());

System.out.println("b in a str ma");

pstm.setString(1,strIdNo);

pstm.setString(2,strDescript);

pstm.setString(3,strSize);

pstm.setDouble(4,dVersionNo);

pstm.setInt(5,nMarked);

pstm.setDate(6,dtDate);

pstm.setInt(8, nFile);

pstm.execute();

con.commit();

return true;

}

[1271 byte] By [bjorko] at [2007-9-27 3:23:21]
# 1

> pstm = con.prepareStatement("INSERT INTO

> INTO Version(Id_Number, Description, Version_Size,

> Version_Number, Marked, Create_Date, The_File,

> File_Record_Number)values ('?','?','?',?,?,?,?,?)");

I guess that should be

pstm = con.prepareStatement("INSERT INTO Version(Id_Number, Description, Version_Size,Version_Number, Marked, Create_Date, The_File,File_Record_Number)values (?,?,?,?,?,?,?,?)");

ie it should be ? and not '?'

kksenji at 2007-7-5 1:12:50 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...