![]() |
to work with database...
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? |
Re: to work with database...
On Fri, 20 Jun 2008 04:02:34 -0700 (PDT), Bumsys@gmail.com 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 |
Re: to work with database...
May I suggest posting to comp.databases.sybase
|
Re: to work with database...
Bumsys@gmail.com 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 |
Re: to work with database...
Roedy Green wrote:
> On Fri, 20 Jun 2008 04:02:34 -0700 (PDT), Bumsys@gmail.com 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 |
Re: to work with database...
In article <0c0e4993-3344-4998-afba-57b16730253d@d77g2000hsb.googlegroups.com>, Bumsys@gmail.com 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 |
| All times are GMT. The time now is 09:32 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.