B
Bumsys
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(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.updateLoop(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.executeUpdate(Unknown Source)
at com.sybase.jdbc3.jdbc.SybPreparedStatement.executeUpdate(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?
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(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.updateLoop(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.executeUpdate(Unknown Source)
at com.sybase.jdbc3.jdbc.SybPreparedStatement.executeUpdate(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?