COUNT field incorrect or syntax error

hi,

PreparedStatement stmt = con.prepareStatement("Insert into uQuestions values(?,?)");

stmt.setInt(1,2);

//stmt.setString(2,s.trim());

Reader rd=new StringReader(s.trim());

stmt.setCharacterStream(2, rd );

System.out.println( stmt.executeUpdate() );

stmt.close();

Result

java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error

In place ofsetCharacterStream If I use stmt.setString(2,s.trim())

then it works fine.

Whats the problem there....

[666 byte] By [Java_persona] at [2007-11-27 5:12:30]
# 1
Are you sure that even compiles?setCharacterStream (at least according to the API doc that I read) takes three arguments.
masijade.a at 2007-7-12 10:33:25 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
It surely compiles.There are two methods of setCharacterStream()1- setCharacterStream(int column, Reader rd);2- setCharacterStream(int column, Reader rd, int length);
Java_persona at 2007-7-12 10:33:25 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
You must be using Java 6 then.The only thing I can say, otherwise, is that the API doc mentions using this for LONGVARCHAR fields. Is that what the field is? Or is it maybe, only a VARCHAR/VARCHAR2?Other than that, I can make no further suggestions.
masijade.a at 2007-7-12 10:33:25 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4
I am using Java 6 already.setClob() and setCharacterStream() are used for NVARCHAR and NTEXT tyes
Java_persona at 2007-7-12 10:33:25 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5

> I am using Java 6 already.

That's what I said in my last post.

> setClob() and setCharacterStream() are used for

> NVARCHAR and NTEXT tyes

Like I said, the API talks about using setCharacterStream for LONGVARCHAR types, are NVARCHAR and NTEXT LONGVARCHAR types?

masijade.a at 2007-7-12 10:33:25 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...