Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   to work with database... (http://www.velocityreviews.com/forums/t621348-to-work-with-database.html)

Bumsys@gmail.com 06-20-2008 11:02 AM

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?

Roedy Green 06-20-2008 11:49 AM

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

Seamus 06-20-2008 12:35 PM

Re: to work with database...
 
May I suggest posting to comp.databases.sybase

Arne Vajhøj 06-21-2008 12:16 AM

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

Arne Vajhøj 06-21-2008 12:17 AM

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

EricF 06-21-2008 05:40 AM

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.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57