Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > to work with database...

Reply
Thread Tools

to work with database...

 
 
Bumsys@gmail.com
Guest
Posts: n/a
 
      06-20-2008
I want to write file to database sybase. I run the following code:

public class TestSybase {
public static void main( String[] args ) {
try {
// Connect to the database

Class.forName("com.sybase.jdbc3.jdbc.SybDriver");
String url = "jdbc:sybase:Tds:10.64.3.27:5000/au12";
Connection con = DriverManager.getConnection(url, "sa",
"");
// Execute the SQL statement
Statement stmt = con.createStatement();

String query = "insert into au_log (logfile) values (?)";
PreparedStatement ps = con.prepareStatement(query);
File file = new File("C:\\Temp\\tttt.rar");
int len = (int) file.length();
if (!file.exists()) {
ps.setNull(1, Types.LONGVARBINARY);
} else if (file.exists() && len == 0) {
ps.setNull(1, Types.LONGVARBINARY);
} else {
InputStream in = new FileInputStream(file);
ps.setBinaryStream(1, in, len);
}

int numberOfRows = ps.executeUpdate();
System.out.println("rows: " + numberOfRows);
ps.close();
stmt.close();
}
catch( Exception e ) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}

If I write a small file to database sybase all is ok. But if a big
file I have error:
com.sybase.jdbc3.jdbc.SybSQLException: There is not enough procedure
cache to run this procedure, trigger, or SQL batch. Retry later, or
ask your SA to reconfigure ASE with more procedure cache.

There is not enough procedure cache to run this procedure, trigger, or
SQL batch. Retry later, or ask your SA to reconfigure ASE with more
procedure cache.

at com.sybase.jdbc3.tds.Tds.a(Unknown Source)
at com.sybase.jdbc3.tds.Tds.nextResult(Unknown Source)
at com.sybase.jdbc3.jdbc.ResultGetter.nextResult(Unkn own Source)
at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unkn own Source)
at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unkn own Source)
at com.sybase.jdbc3.jdbc.SybStatement.updateLoop(Unkn own Source)
at com.sybase.jdbc3.jdbc.SybStatement.executeUpdate(U nknown Source)
at com.sybase.jdbc3.jdbc.SybPreparedStatement.execute Update(Unknown
Source)
at test.TestSybase.main(TestSybase.java:96)

I change procedure cache but I have this error again. What can do that
write a big file to sybase?
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      06-20-2008
On Fri, 20 Jun 2008 04:02:34 -0700 (PDT), http://www.velocityreviews.com/forums/(E-Mail Removed) wrote,
quoted or indirectly quoted someone who said :

> "insert into au_log (logfile) values (?)";


Whatever it would take to configure more procedure space would be
specific to you SQL engine. You won't do it through JDBC. You did not
say what engine you are using.

I am not familiar with that syntax "au_log (logfile)". I would
double check that.

Most databases have a command line interface you can use to perform
experiments. Get your SQL working in that experimental mode before
you add the complexity of Java and JDBC.
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
 
 
 
Seamus
Guest
Posts: n/a
 
      06-20-2008
May I suggest posting to comp.databases.sybase
 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      06-21-2008
(E-Mail Removed) wrote:
> I want to write file to database sybase. I run the following code:


> If I write a small file to database sybase all is ok. But if a big
> file I have error:
> com.sybase.jdbc3.jdbc.SybSQLException: There is not enough procedure
> cache to run this procedure, trigger, or SQL batch. Retry later, or
> ask your SA to reconfigure ASE with more procedure cache.
>
> There is not enough procedure cache to run this procedure, trigger, or
> SQL batch. Retry later, or ask your SA to reconfigure ASE with more
> procedure cache.
>
> at com.sybase.jdbc3.tds.Tds.a(Unknown Source)


> I change procedure cache but I have this error again. What can do that
> write a big file to sybase?


It seems as if you have not increased procedure cache enough.

This is a pure Sybase configuration problem not a Java or JDBC problem.

Arne
 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      06-21-2008
Roedy Green wrote:
> On Fri, 20 Jun 2008 04:02:34 -0700 (PDT), (E-Mail Removed) wrote,
> quoted or indirectly quoted someone who said :
> Whatever it would take to configure more procedure space would be
> specific to you SQL engine. You won't do it through JDBC. You did not
> say what engine you are using.


Actually he did say that he was using Sybase.

>> "insert into au_log (logfile) values (?)";

>
> I am not familiar with that syntax "au_log (logfile)". I would
> double check that.


No ned to.

It is standard SQL syntax to specify column names in an INSERT.

Arne
 
Reply With Quote
 
EricF
Guest
Posts: n/a
 
      06-21-2008
In article <(E-Mail Removed)>, (E-Mail Removed) wrote:
>I want to write file to database sybase. I run the following code:
>
>public class TestSybase {
> public static void main( String[] args ) {
> try {
> // Connect to the database
>
> Class.forName("com.sybase.jdbc3.jdbc.SybDriver");
> String url = "jdbc:sybase:Tds:10.64.3.27:5000/au12";
> Connection con = DriverManager.getConnection(url, "sa",
>"");
> // Execute the SQL statement
> Statement stmt = con.createStatement();
>
> String query = "insert into au_log (logfile) values (?)";
> PreparedStatement ps = con.prepareStatement(query);
> File file = new File("C:\\Temp\\tttt.rar");
> int len = (int) file.length();
> if (!file.exists()) {
> ps.setNull(1, Types.LONGVARBINARY);
> } else if (file.exists() && len == 0) {
> ps.setNull(1, Types.LONGVARBINARY);
> } else {
> InputStream in = new FileInputStream(file);
> ps.setBinaryStream(1, in, len);
> }
>
> int numberOfRows = ps.executeUpdate();
> System.out.println("rows: " + numberOfRows);
> ps.close();
> stmt.close();
> }
> catch( Exception e ) {
> System.out.println(e.getMessage());
> e.printStackTrace();
> }
> }
>}
>
>If I write a small file to database sybase all is ok. But if a big
>file I have error:
>com.sybase.jdbc3.jdbc.SybSQLException: There is not enough procedure
>cache to run this procedure, trigger, or SQL batch. Retry later, or
>ask your SA to reconfigure ASE with more procedure cache.
>
>There is not enough procedure cache to run this procedure, trigger, or
>SQL batch. Retry later, or ask your SA to reconfigure ASE with more
>procedure cache.
>
> at com.sybase.jdbc3.tds.Tds.a(Unknown Source)
> at com.sybase.jdbc3.tds.Tds.nextResult(Unknown Source)
> at com.sybase.jdbc3.jdbc.ResultGetter.nextResult(Unkn own Source)
> at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unkn own Source)
> at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unkn own Source)
> at com.sybase.jdbc3.jdbc.SybStatement.updateLoop(Unkn own Source)
> at com.sybase.jdbc3.jdbc.SybStatement.executeUpdate(U nknown Source)
> at com.sybase.jdbc3.jdbc.SybPreparedStatement.execute Update(Unknown
>Source)
> at test.TestSybase.main(TestSybase.java:96)
>
>I change procedure cache but I have this error again. What can do that
>write a big file to sybase?


I wonder if you'd be better off asking this in a sybase group. Once you start
dealing with BLOBs, which is what you are dealing with, you need to make sure
you are using the correct datatype - and these are proprietary - as well as
the corresponding data type in jdbc, also dependant on the vendor's driver
implementation.

The google search 'sybase jdbc blob' had a number of hits. Try it.

If I knew Sybase I'd try to help.

Eric
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE;Kontki if you delete kontiki any program you loaded with it in it 'will not work I have tried it with three programs and none work anymore (if you se it just stop download) 1-Twitch Computer Support 5 04-23-2009 02:45 PM
MS work around on text wrapping in a datagrid does not work TB ASP .Net 2 02-22-2006 10:34 PM
Hi I am new to asp i can not get it to work on xp pro sp2 even though the localhost work but asp pages dont so can some one help craig dicker ASP .Net 9 07-07-2005 11:52 AM
Re: Those cute little "WORK-SAFE" / "NOT WORK-SAFE" tags that people put in the Subject headers of their posts... Soapy Digital Photography 1 08-16-2004 12:07 PM
Re: Those cute little "WORK-SAFE" / "NOT WORK-SAFE" tags that people put in the Subject headers of their posts... Soapy Digital Photography 1 08-16-2004 06:24 AM



Advertisments