permaculture playing cards
The moose likes JDBC and Relational Databases and the fly likes Problem with JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Problem with JDBC " Watch "Problem with JDBC " New topic

Problem with JDBC

Syed Dastagir

Joined: Dec 06, 2001
Posts: 1
I am using Stored procedure to access a table in Sql Server
7.0.I have a text datatype for one of the fields in the table.
When i access the field for insert using cs.setString()with say
1MB of text the server throws exception. When i use
cs.setAsciiStream instead of cs.setString , am getting exception
when i access the output param. I think this may be a driver
problem. I would like to know whether any of them come accross
this problem and solved it. Any suggesions will be a great help
for me. I have also given the coding below.

[ Edited by Dave to format code ]
[This message has been edited by David O'Meara (edited December 06, 2001).]
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Two things, if you try using the JdbcOdbcDriver you will always run in trouble. It doesn't implement all JDBC methods and it isn't very stable.
Secondly: My view (and I'm no DBA) is don't put a 1Mb file in the database. Personally I'd store a reference to where the file is stored externally or something.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

sent via email:
Hi david,
I got ur reply. Thanks for responding. Since i get the text from the form(its a description field) and storing it in the DB, there is no chance for storing it in the file. And more over there will be no security. If say am storing some 10000 recs then managing my files will become hectic problem.


(Sorry I can't usually reply via email, and it means no-one else can get a say )
If you are getting the data via a HTML form, you can either use a multipart/form-encoded upload, save it to the local file system and save the filename in the db, or receive the data as a form field, write it as a unique file name (since you control the data) and once again save the file name in the DB.
The other problem I've seen that you may run into if you try to store the data direct top the DB is that there are often still upper limits on how large LOB types can be (32k or so? I can't remember)
I agree. Here's the link:
subject: Problem with JDBC
jQuery in Action, 3rd edition