to work with database...

Discussion in 'Java' started by Bumsys@gmail.com, Jun 20, 2008.

  1. Guest

    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?
     
    , Jun 20, 2008
    #1
    1. Advertising

  2. Roedy Green Guest

    On Fri, 20 Jun 2008 04:02:34 -0700 (PDT), 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
     
    Roedy Green, Jun 20, 2008
    #2
    1. Advertising

  3. Seamus Guest

    May I suggest posting to comp.databases.sybase
     
    Seamus, Jun 20, 2008
    #3
  4. Arne Vajhøj Guest

    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, Jun 21, 2008
    #4
  5. Arne Vajhøj Guest

    Roedy Green wrote:
    > On Fri, 20 Jun 2008 04:02:34 -0700 (PDT), 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
     
    Arne Vajhøj, Jun 21, 2008
    #5
  6. EricF Guest

    In article <>, 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(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?


    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
     
    EricF, Jun 21, 2008
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luis Esteban Valencia
    Replies:
    1
    Views:
    1,416
    Carl Prothman [MVP]
    Jan 12, 2005
  2. =?Utf-8?B?U1M=?=
    Replies:
    3
    Views:
    3,871
    Juan T. Llibre
    May 15, 2005
  3. Replies:
    8
    Views:
    476
  4. casper
    Replies:
    0
    Views:
    9,083
    casper
    Apr 24, 2006
  5. Keith
    Replies:
    1
    Views:
    2,354
    Keith
    Jul 3, 2006
Loading...

Share This Page