*
The moose likes JDBC and the fly likes Problem with setBinaryStream Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem with setBinaryStream" Watch "Problem with setBinaryStream" New topic
Author

Problem with setBinaryStream

Subash Kshetri
Greenhorn

Joined: May 18, 2011
Posts: 23

Hello

I am having a problem with PreparedStatement.setBinaryStream(1,x,y), it works for files with smaller size but for a file of 15 Mb the file downloads easily but while uploading it returns -1 in statement.executeUpdate(). I looked over many places in google and found that PreparedStatement.setBytes worked for some but it didn't for me and now i am just repeating every methods found in forums but am stuck at the same point , so plzzzzz help me with this.

Thank you in advance.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What driver are you using?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Subash Kshetri
Greenhorn

Joined: May 18, 2011
Posts: 23

driver is probably 4.0......the live production server is in a different country
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What implementation are you using? Oracle? SQL Server? MySQL? DB2? Postgres?

What version and type is the database?

Can you post your code?
Subash Kshetri
Greenhorn

Joined: May 18, 2011
Posts: 23

Database is MSSQL 2008

Database type is relational

The code is


this function is called from another page and after this function is completed the program returns -1 in statement.executeUpdate();
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Would that be SQL Server 2008 Enterprise Edition, or the developer edition?

What driver implementation are you using? What data type is the target field? Is SQL Server running in a compatability mode less than 100?
Subash Kshetri
Greenhorn

Joined: May 18, 2011
Posts: 23

Enterprise edition,
Data type is Image,

I don't have the access to production server database so i don't know about the driver implementation and SQL Server compatibility mode but i can request for those things .... what can i do after getting those parameters...
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You don't need access to the DB for either. You can query for compatability mode via Entirprise Manager and you will have the driver in your classpath.

The image data type will hold 2GB of data, so its not likely to be the database. Sounds like a driver issue perhaps.
Subash Kshetri
Greenhorn

Joined: May 18, 2011
Posts: 23

DBDriver is com.microsoft.sqlserver.jdbc.SQLServerDriver and could you please explain what might be driver issues ..
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Which version of that driver?
Subash Kshetri
Greenhorn

Joined: May 18, 2011
Posts: 23

4.0
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

There isn't a version 4.0 as far as I am aware. Where did you get it?

Another question: does the data actually get inserted? Is it just the return value that is the issue?
Subash Kshetri
Greenhorn

Joined: May 18, 2011
Posts: 23

I dont know where they got but that is the version of jdbc driver they are using for live production server and local as well.

No the data doesn't get inserted into the db.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Hmm. Well there is no version 4.0 supplied by Microsoft.

Have you tried using another method to set the Binary content? What happens if you define the length? Or use setBlob()?
Subash Kshetri
Greenhorn

Joined: May 18, 2011
Posts: 23

Thank you Paul for helping me but i don't have the exact information about the production server database and have requested those and so i can't figure out what to do unless i get the details of the database and the constraints of the column. Thank you again.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You are welcome. Are aware you can get the information you need by querying the database? exec sp_help on the table in question will tell you all you need to know about the table and column. exec sp_dbcmptlevel will tell you the compatability level (though reading the docs this probably does not matter in your case, image has always supported 2GB).
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with setBinaryStream
 
Similar Threads
Setting Load balancer for JBoss using Apache and mod_jk
How do you include libraries (JMF specifically)?
error while loading a class
Problem in deploying ear file in weblogic 6.1
WAS 3.5.6 problem