Problem in addBatch method in java.sql.Statement Interface

Hi
I am facing a problem java.lang.UnsupportedOperationException when using addbatch() method of java.sql.Statement Interface.
Please suggest solutions.
Thanks
nsgindia

Your JDBC driver doesn't support batch operation, try another driver(not all databases support batch'es eg MySQL)

Similar Messages

  • Java.beans.Statement & java.sql.Statement

    My old code from jdk1.3.1 throws the ambiguous class thingie-mo-bob. Why did they implement the new java.beans.Statement, and is there anyway to make it default to the old java.sql.Statement without having to go through all the old code and add import java.sql.Statement. I have like 200 jsp files 'n it will take a loooong time!
    Pete

    There r two ways to do this.
    (i) One is Implement the java.sql.Statement
    like
    package java.beans;
    public interface Statement implements
    java.sql.Statement {
    }What? Are you suggesting he edit the source code for java.beans.Statement and make it implement java.sql.Statement?? I would most certainly not suggest that solution- beside violating the licensing agreement, it has troubling consequences since you are basically redefining the structure of a class in a way that makes no functional sense- that is, there is no reason for java.beans.Statement to implement methods like getConnection() and the other signatures of java.sql.Statement.
    I'm not sure if I'm reading your response correctly or not, but I would definitely not refactor java.beans.Statement just to get this problem solved with out editing files ... ... since java.sql.Statement is used so widely, perhaps they should have considered a different name for java.beans.Statement , although you hate to base a name off of what's going to cause the least problems, rather then what makes the most sense ... ... any way, I guess it doesn't matter now: the name has been selected .... I'd be interested to hear how you solved the problem.

  • Problem in Calling a function in sql statement.

    hi,
    I am having a function ops_safex_utl.EDIT_ASSC_CNTR_LOG(id number);
    when i am trying to use this inside a sql statement as shown below, it is giving error (exception part inside the function).
    SQL> select ops_safex_utl.EDIT_ASSC_CNTR_LOG(688) from dual;
    OPS_SAFEX_UTL.EDIT_ASSC_CNTR_LOG(688)
    -1 (-- exception )
    when i am trying to call this function using a PL/SQL Block then it is woking fine as shown below.
    SQL> DECLARE
    2
    3 x NUMBER(2);
    4
    5 BEGIN
    6
    7 x := ops_safex_utl.EDIT_ASSC_CNTR_LOG(688);
    8
    9 dbms_output.put_line('x '||' '||x);
    10
    11 END;
    12 /
    hi
    insert into ops_assc_cntr_log
    insert into ops_ac_ex_gratia_log
    insert into ops_ac_sls_dlvry_slab_dtls_log
    insert into ops_ac_sls_dlvry_slab_dtls_log
    insert into ops_ac_sls_dlvry_slab_dtls_log
    insert into ops_ac_sls_dlvry_slab_dtls_log
    insert into ops_ac_sls_dlvry_slab_dtls_log
    insert into ops_ac_spl_acct_dtls_log
    insert into ops_ac_spl_acct_slab_dtls_log
    insert into ops_ac_spl_acct_slab_dtls_log
    insert into ops_ac_spl_acct_slab_dtls_log
    insert into ops_ac_spl_acct_dtls_log
    insert into ops_ac_spl_acct_slab_dtls_log
    insert into ops_ac_spl_acct_slab_dtls_log
    insert into ops_ac_spl_acct_slab_dtls_log
    update ops_assc_cntr
    success
    x 0
    PL/SQL procedure successfully completed.
    when i am trying to run the SQL statement it is returning a exception from the function.
    SELECT ops_safex_utl.EDIT_ASSC_CNTR_LOG(688) from dual --it is returning -1 (i.e exception).
    My sql client version is 9.2.0.1.0. and my data base version is 10.2.0.2.0.
    Please advice.

    Could you post the exception handler within the function.
    It sounds like you return -1 if you experience an error - it would be easier to determine the cause of the problem if you return the Oracle error details, E.g:
    EXCEPTION
       WHEN OTHERS THEN
          RETURN dbms_utility.format_error_backtrace;This will then return a meaningful error, identifying exactly what is causing the error to be generated.

  • MS Access queries different to Java SQL statements

    Ok, i dont understand something:
    My program is connected to a MSAccess datasource. The query in MSAccess is
    SELECT *
    FROM Food_Data
    WHERE Description Like 'Cheese*';
    ...but this wont work with a Java SQl query. I have to use this instead:
    String query = "SELECT * FROM Food_Data " +
              "WHERE Description LIKE 'Cheese%'";
    Surely java would just passes the string query to MSAccess. But no. Java needs '%' as the wildcard, and MSAccess needs '*' as the wildcard.
    Can anyone please explain this to me?

    Well % is the standard wildcard character for SQL as defined by the ANSI standard. MS Access just doesn't conform to this standard.
    Having said that, I'm still kind of astonished that it doesn't work :-)
    The JDBC driver should pass the statement "as is" to the underlying DBMS, but obviously the JDBC/ODBC bridge does some "quirking". But maybe it
    s the ODBC datasource. I can see a "ExtendedAnsiSQL" setting in one of my Access ODBC settings, maybe that changes something.

  • Java.sql.Wrapper Interface in Java6. Why?

    Can anybody tell me why is there Wrapper interface in Java6? (I mean java.sql package)
    I would be glad if you can provide me with some sample source code.

    I have already declared bind variable in VO. Values all passed to i have debug the program.
    Here is the my query
    SELECT
    SUM(NVL(R.AMOUNT, 0) - NVL(R._AMOUNT, 0))
    FROM
    Payments C,
    RECEIPTS R
    WHERE
    R.ID = :pId AND R.TYPE = :pType AND R.PAYMENT_MODE = 'CHEQ' AND R.PAYMENT_MODE_TRAN_NO = C.CHQ_TRAN_NO AND C.CHEQUE_STATUS IN ('SUSPEND','KEEP')
    This is the code for access view object.
    ViewObjectImpl vvoAmount =
    getUnRealizedChequeAmountVVO();
    vvoAmount .setNamedWhereClauseParam("pId", bId);
    vvoAmount .setNamedWhereClauseParam("pType",
    bType);
    vvoAmount .executeQuery();
    vvoAmount .first();

  • Problem finding native methods in java packages

    Hi,
    I have a java class which uses some native methods written in OCamL. I wrote a C file which calls the OCamL code, and created the corresponding shared library using the jni. I then tested my java file and everything works fine, I can nicely call the OCamL functions. However, I need this java file to be included in a package, but whenever I add the line:
    package somepackage;
    on top of the java code, my java file simply doesn't seem to find the C and OCamL implementation anymore :
    javac -cp :./path/of/somepackage
    -Djava.library.path=/full/path/of/somepackage MyProgram args
    Exception in thread "main" java.lang.UnsatisfiedLinkError:functionName
    at somepackage.ClassName.functionName(NativeMethod)
    I have of course put everything (java, C, .h , libsomelibrary.so, and OCamL files) in a directory called somepackage, and written another java file which creates an instance of the first one from outside the package, imports the package, and calls its methods in main(). It just doesn't work anymore.
    I then added a simple hello-world function (not C nor OCamL code) to the java file inside the package. And when invoked from outside, it worked. Question is then... Am I forgetting something to be done, in order to get C and CamL files efectively included in the java package (same as "package somepackage;" in C or OCaml, perhaps)??? Why isn't the java file able to find them inside its very own directory (having into account that without the package definition it worked well)?
    Thanks,
    PS Im using jsdk 1.4.1 on lunyx redhat 8.0

    Did you change the name of the function in the library, too?
    If the function name was
    "Java_YourClass_functionname",
    it should be now
    "Java_path_to_your_package_YourClass_functionname".

  • GetScale(int) method of java.sql.ResultSetMetaData

    On weblogic 8.1 instance I am using oracle JDBC TYPE 4 Thin driver.
    The jar file for the driver is ojdbc14.jar.
    Our database is 9.2.0.
    code excerpt:
    //rs is the resultset
    if (rs != null)
    ResultSetMetaData RSMD = rs.getMetaData();
    int i = RSMD.getColumnCount();
    int test=0;
    String cName="";
    for(int j = 1; j <= i; j++)
    test = RSMD.getScale(j);
    cName = RSMD.getColumnName(j);
    System.out.println("The scale of column name : "+cName+ " is " +test);
    The output is:
    The scale of column name : PERSON_ID is -127
    The scale of column name : FIRST_NAME is 0
    The scale of column name : LAST_NAME is 0
    The data type of column PERSON_ID is NUMBER. Why is it so? getScale(int) should return zero for a column whose data type is NUMBER.
    Help me. Is it driver specific probelm?

    Hi,
    I have a similar problem. I want to find out the column names when i fire raw-sql. I use SQLCall to do this.
    Then I get a Vector<DatabaseRow>.
    Vector vDR = session.executeQuery( new SQLCall( "select * from table_name" ) )
    Now Is there a way to find out the column names dynamically. In the javadocs i see that objDatabaseRow.keys() returns an Enum<DatabaseField>... but i cant see javadocs on how to use DatabaseField.
    So is there any other way ?
    Thanks,
    Krishna

  • Java.sql.Statement hangs

    I'm having trouble executing the following statement. It never moves past execute(String sql)
    execute("insert into wtchangerequest2master(IDA2A2,WTCHGREQUESTNUMBER,MARKFORDELETEA2) select IDA2A2,WTCHGREQUESTNUMBER,MARKFORDELETEA2 from ccrmaster where ccrmaster.ida2a2=239207");
    whereas the following line executes perfectly
    execute("select distinct ida2a2 from ccrmaster");
    The statement that fails with Statement.execute works in sqlplus.
    Anybody have any ideas?

    Println("1 pre select");
    Execute("select ...");
    Println("2 post select");
    Println("3 pre insert select");
    Execute("insert ... Select ...");
    Println("4 post insert select");
    The app prints 1, 2, and 3, but hangs on the second execute and never gets to 4. No exception, no stack trace. It doesn't terminate. It just sits there.
    The pseudo might be a little rough.. I sent this from my phone.

  • Problem in using Timestamp from java.sql.*

    AOA
    i have declared a variable
    private Timestamp entryDate = new Timestamp(8);while using it in my application. it inserts similar time stamp in database , like
    01/01/1970 5:00:00 AM
    How to get current time from it and how to insert it in databse.

    AOA
    i have declared a variable
    private Timestamp entryDate = new Timestamp(8);
    Why? What does that 8 mean to you? Did you read the docs to see what it means to Timestamp?
    >
    while using it in my application. it inserts similar
    time stamp in database , like
    01/01/1970 5:00:00 AM
    How to get current time from it and how to insert it
    in databse.Did you read the docs for Timestamp? There's a constructor and/or a set method that takes a Date or a number of millis. You can get the current time in millis with System.currentTimeMillis. (I think that's the method name. Look at System's docs.)
    As far as inserting it, you'll do something like this: TimeStamp ts = ...;
    Connection con = DriverManager.getConection(...);
    PreparedStatement ps = con.prepareStatement("insert into foo (bar) values (?)");
    ps.setTimestamp(1, ts);
    ps.executeUpdate(); Google for jdbc tutorial for more details.

  • About java.sql.Statement

    Hi friends, i want to ask if there is any way to display the complete statement as a string after setting it's parameters(that is for debuging purpose).

    Hi friends, i want to ask if there is any way to
    display the complete statement as a string after
    setting it's parameters(that is for debuging purpose).JDBC related questions should be asked in the JDBC forum.
    Your subject line is contraindicative to your question which is about PreparedStatements.
    The answer to your question is no. You can however use a tracing driver that will log your queries so that you can see what is going on. Look at http://www.p6spy.com/

  • Java.sql.Statement: setQueryTimeout(int seconds) ???

    Anyboby knows if this method is working with MySQL-Connector JDBC driver ?
    If not, is there another way to time out a select query ?
    Thanks a lot
    Ludovic

    Do you have an idea of how I can test it ?Well you can time a select query and afterwards set the timeout interval to a value less than the time of the query. Start the same query and check the results.
    So long.

  • Java.sql.Statement.setFetchSize(int) option for non-scrollable result sets

    Hello!
    Our tests indicate that fetch size option mentioned makes visible difference in performance for non-scrollable result sets also. In the same time, it seems there is no way to set this option for such result sets at TopLink level, and default fetch size is always used instead.
    Can somebody propose a solution for this, I mean a way to specify custom fetch size (for results without any scrolling)?
    Thanks,
    Sergey

    To set the JDBC fetch size for a query, use the following APIs:
    int desiredFetchSize = 500;
    ReadAllQuery query = new ReadAllQuery(YourClass.class);
    CallQueryMechanism queryMechanism =
    (CallQueryMechanism) query.getQueryMechanism();
    DatabaseCall call = queryMechanism.getCall();
    call.setResultSetFetchSize(desiredFetchSize);
    If you wish to set the fetch size for all queries, consider using named queries for all queries (see the TopLink documentation for more information on named queries), and then configure them on startup.
    Information taking from Metalink Note:237093.1

  • Problem on setFetchSize() method

    when i use the setFetchSize() method, should i still use while loop to retrieve data? (code snippets below)
    Statement stmt = con.createStatement();
    stmt.setFetchSize(4)
    ResultSet rs = stmt.executeQuery("select * from customers");
    while (rs.next())
    System.out.println("SkuCode-"+rs.getInt(1));
    when run, still, all contents in the database are retrieved. i just need to retrieve the first 4, then the next 4, and so on....
    thanks,
    jen

    Hi,
    setFetchSize(int) defines the number of rows that will be read from the database when the ResultSet needs more rows. The method in the java.sql.Statement interface will set the 'default' value for all the ResultSet derived from
    that Statement; the method in the java.sql.ResultSet interface will override that value for a specific ResultSet. Since database fetches can be expensive in a networked environment, fetch size has an impact on performance.
    setMaxRows(int) sets the limit of the maximum nuber of rows in a ResultSet object. If this limit is exceeded, the excess rows are "silently dropped". That's all the API says, so the setMaxRows method may not help performance at
    all other than to decrease memory usage. A value of 0 (default) means no limit.
    I am trying to simulate your case, please give me some time.
    Thanks
    Bakrudeen

  • Does Java support mutliple sql statements in one call?

    statment.executeUpdate("DROP DATABASE IF EXISTS diy55;CREATE DATABASE IF NOT EXISTS diy55 DEFAULT CHARACTER SET utf8;GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX,USAGE on diy55.* TO 'diy55'@'localhost' identified by 'diy55';FLUSH PRIVILEGES;");Java seemes doesn't support multiple sql statements in one call, just like PHP mysql_query(), is it?

    Then just extend the java.sql.Statement to your own Statement class and write logic which splits the given query at the right places and executes them one by one.
    That the mysql_query() already has it built-in wouldn't say that it isn't possible in Java. Comparing with PHP is a bit pointless, it is a completely different language.

  • Problems in using SQL statement

    Is that a way that i could use java sql statement for COUNT or SUM SQL Statement
    String query = "SELECT S.Name,COUNT(TS.NoOfPoints) AS Points FROM TeamS,TeamStatistics TS WHERE S.TeamID = TS.TeamID ORDER BY TS.NoOfPoints DESC";
    i am trying to count the num of points for each team.
    I have eror message,execute the sql statement
    is the sql statement correct.

    String query= "SELECT S.TeamName,COUNT(TS.NoOfPoints) FROM Team T,TeamStatistics TS GROUP BY T.TeamName HAVING T.TeamID = TS.TeamID";
    Statement statement = connection.createStatement();
    ResultSet rs = statement.executeQuery(query);
    while(rs.next())
    System.out.println(rs.getString("TeamName"));
    System.out.println(rs.getString("NoOfPoints"));
    The sql doesn't work, i really dun konw what to do

Maybe you are looking for