JDBC , UPDATE STATEMENT

I am writing a Update Statement as fllows
String sql= "update users_login set user_temp_pass='"+null_value+"' and user_pass='" + inputPwd + "'where user_id='"+inputUserid"';";
But is still showing error saying that
the statement has to be terminated by a ';'
Please help me writing the statement correctly.

Thank you, I have one more question.
I am writing the following code to erase the temporary password and put the user choosen password.Somehow this is returning TRUE but the same changes are not appearing in the database.Please help me solving that.
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
// Connection con = DriverManager.getConnection("jdbc:oracle:thin:@wdcorcl01dev:1521:USAD", "osis", "iss");
con = DriverManager.getConnection("jdbc:oracle:thin:@wdcon01dev:1521:USAD", "osis", "iss");
if (con == null) {
System.out.println("Connection not found");
stmt = con.createStatement();
con.setAutoCommit(false);
String sql= "update isis_users_login set user_temp_pass='"+null_value+"',user_pass='" + inputPwd + "'where user_id='" inputUserid "'";
stmt.executeUpdate(sql);
con.commit();
returnString= true;
} catch(SQLException sqlex) {
sqlex.printStackTrace();
returnString=false;
} catch(Exception ex) {
ex.printStackTrace();
} finally {
stmt.close();
con.close();
stmt = null;
rs = null;
con = null;
return returnString;

Similar Messages

  • SAP XI JDBC update SQL statement

    Hi,
    I am new to JDBC to RFC configuration and is currently on a deadlock.
    We are running a real time JDBC update statement where records are created based on employee login. We have configured the sender adapter to retrieved 5 records for every 5 seconds using the SQL query below:
    select *  from dtable where  uploaded=false order by recordno asc limit 5;
    and update using:
    update dtable set uploaded=true where uploaded=false order by recordno asc limit 5;
    The problem is that when there are only 3 records retrieved in the selection, the update statement always update 5 records back. This makes records created in-between the select and update to be updated as well.
    Can anyone suggest the correct update statement? Can I use the record numbers retrieved from the first statement in the update?
    Thanks,
    Ryan

    Hi,
    >>>>Can anyone suggest the correct update statement?
    1. you have a few choices but one of them would be to use a stored procedure in the select statement (which would have both select and update statements)
    2.
    a) select *  from dtable where  uploaded=false order by recordno
    b) update dtable set uploaded=true where uploaded=false
    c) split them by 5 rows in the mapping (multimapping)
    Regards,
    Michal Krawczyk

  • Execution time difference between SELECT & UPDATE statement in JDBC Sender.

    Hi Experts,
    In my scenario, I have used the JDBC Sender Adapter with the SELECT and UPDATE statement.
    Now the problem is in between the execution of Select and update statement, few more entries are coming in the same DB Table.
    So result of this is updation take place for those entries which are not even picked up by the select statement.
    Can we avoid this execution time difference between the SELECT & UPDATE statemet on JDBC Sender side???
    Thanks & Regards
    Jagesh

    Hi
    Use serializable option in additional parameters, now all new entries would also be updated.

  • JDBC Sender Adapter, Update statement

    Hi ALL,
               I have a JDBC to proxy scenario. We have stored procedure in the database that executess and sends the data to SAP.
    Also the same store procedure updates the field Status_ID to distinguish between read and unread records. Status_ID acts as a Flag.
    Now because the Stored procedure itself does what 'Update SQL Statement' in sender JDBC adapter does, what shall I put in 'Update SQL Statement' as it is not needed, but it's a mandatory field??
    XIer
    Message was edited by:
            XIer

    Do you need that update in the sender jdbc adaptor to do anything....?
    Dint think so..
    Change your update statement to update Status_ID if its not updated..and if the sql procedure has run already then its not going to be updated ..as it already is.......
    Regards
    Ravi Raman

  • Update- statement in JDBC sender Adapter

    Hi ,
    I have a requirement where I am trying to fetch data from ODS based on some flag and immediately I want to update the flag status . So I used selected and update in JDBC sender adapter .
    But I have one question , in the small timeframe where  XI has done a select and just before  XI could  issue the update statement  if a new record is added to ODS . Then  that new record will also get updated though it wasnot selected in select statement .
    Can someone let me know how to overcome this problem ; as I want to make sure I update only those recrods which are selected in select statement ??
    Thanks & Regards,
    Suvarna

    Hi,
    Check out the following thread. It gives the exact answer to this question.
    JDBC Sender Update Query
    One of the replies in the above thread:
    I put in an OSS note asking this exact question with your specific example, and got a reply. I was referred to OSS note 0000831162, where it is explained very unambiguously that the SELECT and UPDATE queries are run in the same transaction.
    Regards,
    P.Venkat
    Message was edited by:
            Venkataramanan

  • UPDATE statement in Receiver JDBC adapter

    Hi all,
    I would like to use UPDATE statement in my receiver JDBC adapter and would like to know how this UPDATE statement works in following case.
    1) If i have 10 records to be updated in database, whether Commit happens at the end of all 10 records updation OR it will be for every record update?
    Regards

    Hi,
    Then let me construct my query this way...
    i have 10 records that needs to be updated to database, say For Ex: 7 records are updated successfully and 8th record has issue in updating the table.
    In this case i would like to ROLLBACK entire 10 records with out committing any thing.
    So if i use your 2nd option, it should perform as i expected right?
    Regards

  • JDBC adapter - update statement

    I have come to the conclusion that there is no direct connection between the select and update statement of a sender JDBC adapter, in terms of commit scope.
    According to SAP documentation:
    "The UPDATE statement must alter exactly those data records that have been selected by the SELECT statement. You can ensure this is the case by using an identical WHERE clause. (See Processing Parameters, SQL Statement for Query, and SQL Statement for Update below)."
    But my point is: if select statement retrieves e.g. 5 rows based on a where condition, then the update statement could find 6 rows to update, if a row was inserted a split second after the select, but before the update. Result : a row is lost...
    I don't think the select statement puts a lock on the table(s) it accesses, and releases this lock after update has been committed. This would ensure integrity between select and update statement.
    Can anybody confirm or deny this ?

    Hi,
    Have you seen the<b> Isolation level for Transaction handling</b> in the sender JDBC adapter?
    Make the Isolation level as Serializable and repeatable Read and the db gets locked  anbd until Update happens, no Insertion can occur in the Split Second!
    http://help.sap.com/saphelp_nw04/helpdata/en/7e/5df96381ec72468a00815dd80f8b63/content.htm
    Regards,
    Bhavesh

  • Sender JDBC: help to construct Update statement

    Hi,
    I need help in writing a update statement to DB2 database in sender JDBC adapter.
    The sender adapter picks up only few records say 10 at a time which match the Select query condition. So I would need to update only those selected "n" records and not all the records that match the Select query condition.
    Select looks like :
    Select * from <table> where <condition> fetch first <n> rows only.
    But it is not allowing the following update
    update <table> set <field> = <value> where <field> IN (Select * from <table> where <condition> fetch first <n> rows only)
    The above statement errors because DB2 does not allows u201CFetchu201D statement within the update sub query.
    Any pointers to a write update statement for n records is highly appreciatedu2026
    ~SaNvu2026

    Hi Santosh,
    In JDBC Sender Adapter provide the following select & update statements
    Select Statement:
    select * from <table> where <condition> AND ROWNUM<N (N==No.of Rows)
    Update Statement:
    update <table> set <field> = <value> where <field> IN (Select * from <table> where <condition> AND ROWNUM<N)
    (N==No.of Rows)
    And for the error you are facing is because of the server communication link failure between the two systems.
    Check the connections and try to stop & start communication channels once.
    Regards
    Venkat Rao .G

  • JDBC: Syntax error in UPDATE statement???

    Hi,
    I have been trying to solve this seemingly simple problem for the past 4 hours, and I had no success. I am working on a jdbc:odbc connection which utilizes MS Access. I have been constantly getting "Syntax error in UPDATE statement", and this is the statement
    (name of the table is CDs, columns are number, artist, album, label and date - all strings):
    query = "UPDATE CDs SET artist = '" + fields.artist.getText() +"', album = '" +
    fields.album.getText() + "', label = '" +
    fields.label.getText() + "', date = '" +
    fields.date.getText() + "' WHERE number = '" + fields.number.getText() + "'";
    Can anybody recognize an error? Thank you,
    mirkokrug

    A couple of possibilities.
    If the column NUMBER is numeric then it wouldn't need quotes around the data value. Also if the column DATE is a date or date/time type then the format from the textbox may not be correct.
    Col

  • Update statement problem for jdbc adapter

    Hi all
    In the jdbc sender adapter, I configured as follows:
    Query statement
    select * from pickdiff where tid is null
    Update statement
    delete from pickdiff where tid is null
    I got following error message:
    Database-level error reported by JDBC driver while executing statement 'delete from pickdiff where tid is null'. The JDBC driver returned the following error message: 'java.sql.SQLException: [SQLServer 2000 Driver for JDBC][SQLServer]Die Unterabfrage gab mehr als einen Wert zurück. Das ist ungültig, wenn die Unterabfrage auf =, !=, <, <= , >, >= folgt oder als Ausdruck verwendet wird.'. For details, contact your database server vendor.
    If I change the Update statement to
    update pickdiff set tid = 'sapxi' where tid is null
    Then everything is ok.
    Doese any one have some idea about this problem?
    Regards
    Hui

    Hi,
    The below statements are from SAP help...
    http://help.sap.com/saphelp_nw04/helpdata/en/7e/5df96381ec72468a00815dd80f8b63/frameset.htm
    The UPDATE statement must alter exactly those data records that have been selected by the SELECT statement. You can ensure this is the case by using an identical WHERE clause. (See Processing Parameters, SQL Statement for Query, and SQL Statement for Update below).
    &#9679;      Processing can only be performed correctly when the isolation level for transaction is set to repeatable_read or serializable.
    SQL statement for query: SELECT * FROM table WHERE processed = 0;
    SQL statement for update: UPDATE table SET processed = 1 WHERE processed = 0;
    processed is the indicator in the database.
    please see if setting the isolation level would help....Also are you getting this error always or is it intermitent ?
    Thanks,
    Renjith

  • JDBC and using update statements

    I have a program that connects to a microsoft access DB using JDBC-ODBC Bridge, but i dnt know how to write a correct update statement. I use servlets & it should call a function that retrieves a specific value, adds 1 to that integer value and updates the DB,but it didn't work. i also need to know how to delete all records in a DB.
    Thanks in advance

    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.sql.*;
    public class first_count extends HttpServlet {
       private Statement statement = null;
       private Connection connection = null;
       private String URL = "jdbc:odbc:rjdemo";
       public void init( ServletConfig config )
          throws ServletException
          super.init( config );
          try {
      Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
          connection =DriverManager.getConnection( URL, "", "" );
            }//try
           catch ( Exception e )
             e.printStackTrace();
             connection = null;
          }//catch
       public void doPost( HttpServletRequest req,
                           HttpServletResponse res )
          throws ServletException, IOException
          String cnt;
          cnt = req.getParameter( "big" );
    //takes the parameter of a radio button in a form
         PrintWriter out = res.getWriter();
          res.setContentType( "text/html" );
         if ( cnt.equals("big1"))
    //if the value of the radio button equals big1
             int i=0;
             out.println("The number retrieved = " + big_counter(i));
                      }//if
            out.close();
    int big_counter(int i)
          try {
             i=0;
             statement = connection.createStatement();
             ResultSet r= statement.executeQuery("select beg_count from User");
             r.first();
             i=r.getInt("beg_count");
    //the name of column is beg_count it's a number
             i++;
             statement.executeUpdate("UPDATE User SET beg_count="+i);
             statement.close();
          }//try
          catch ( Exception e )
          }//catch
    return i;
       public void destroy()
          try {
             connection.close();
          catch( Exception e ) {

  • [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.

    Hi,
    I am getting following error message ,
    [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.
    When run this code.
    <%@ page import= "java.sql.*"%>
    <%
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:bspipdb");
    Statement st = con.createStatement();
    st.executeUpdate("update tscipshift set 11-Aug-08='M' where TechN='Elamparuthi'");
    %>
    tscipshift=table ,column=11-Aug-08 are all exist.
    I dont know why I am getting error mesage.
    Any idea why?

    Shahbaz2008 wrote:
    you haven't set your user name and password hereI don't believe that's necessary with Access. Then again, it's not an enterprise database.
    Connection con = DriverManager.getConnection("jdbc:odbc:bspipdb");
    change it to this
    Connection con = DriverManager.getConnection("jdbc:odbc:bspipdb","+username+","+password+");
    here pass your username and password...
    In Oracle default user name and password is
    username = scott
    password = tigerSo who uses that? Only an eejit would leave that account open.
    So the statement would be
    Connection con = DriverManager.getConnection("jdbc:odbc:bspipdb","scott","tiger");
    or In Mirosoft Access there is no user name and password so the statement will be Like I said - unnecessary, and not the reason the OP is having problems.
    Connection con = DriverManager.getConnection("jdbc:odbc:bspipdb","","");>
    Besides this change your table name 11-Aug-08 to anything that is not start with number or any special symbols.
    for example aug112008 is good or aug is too good.No, it's still not good if you understand ANYTHING about relational databases and normalization.
    I think it would work.I think you're just as stup!d as the OP.
    %

  • Multiple UPDATE statement in a message

    Hi Experts,
    Here is a scenario where we need to send multiple UPDATE statements in single message
    the structure is as below.
    <Table_name> 0..unbounded occurrence
               <action> UPDATE
               <access>
                       <non key fields>
               </access>
               <key>
                       <key fields>
               </key>
    in the above case the node <Table_name> would occur multiple times, the issue is only the first occurrence of the update statement is executed, rest of the update statements are ignored.
    did my approach is wrong, please help...
    thanks.

    Bandana,
    No your approach is not wrong. But you may need to tweak little bit to get your requirement correctly.
    Please follow Raj or Jais reply in this threads:
    JDBC Receiver - Multiple rows Update
    JDBC receiver multiple records UPDATE
    But with this approach it would be multiple calls. If I were you I would write SQL_DML statement to update all at once.
    Regards,
    ---Satish

  • JDBC Update Failed in JTable Interface

    A connection is established to database and the JTable gets the details from database and displays it in the form of a JTable as normal. When i edit just one cell, the update is processed successfully, however when try to update second cell on that particular table, the update would fail. It seems that the second update doesnt actually generate a SQL update statement to execute on database. If anyone has come across such a problem, could you please let me know what i am doing wrong here. I am using an instance of this class to create each JTable on my GUI:
    import javax.swing.JTable;
    import javax.swing.JScrollPane;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    import javax.swing.JOptionPane;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Vector;
    import java.sql.*;
    import javax.swing.table.AbstractTableModel;
    import javax.swing.event.TableModelEvent;
    public class TableGen extends JFrame {
    public JTable table1;
    public JScrollPane scrollPane;
    private boolean DEBUG = true;
    public TableGen(String squery) {
    JDBCAdapter tabl = new JDBCAdapter("jdbc:odbc:ereg", "sun.jdbc.odbc.JdbcOdbcDriver",
    null,null);
    tabl.executeQuery(squery);
    table1 = new JTable(tabl);
    table1.setPreferredScrollableViewportSize(new Dimension(500, 70));
    //Create the scroll pane and add the table to it.
    scrollPane = new JScrollPane(table1);
    //Add the scroll pane to this window.
    class JDBCAdapter extends AbstractTableModel {
    Connection connection;
    Statement statement;
    ResultSet resultSet;
    String[] columnNames = {};
    Vector          rows = new Vector();
    ResultSetMetaData metaData;
    public JDBCAdapter(String url, String driverName,
    String user, String passwd) {
    try {
    Class.forName(driverName);
    System.out.println("Opening db connection");
    connection = DriverManager.getConnection(url, user, passwd);
    statement = connection.createStatement();
    catch (ClassNotFoundException ex) {
    System.err.println("Cannot find the database driver classes.");
    System.err.println(ex);
    catch (SQLException ex) {
    System.err.println("Cannot connect to this database.");
    System.err.println(ex);
    public void executeQuery(String query) {
    if (connection == null || statement == null) {
    System.err.println("There is no database to execute the query.");
    return;
    try {
    resultSet = statement.executeQuery(query);
    metaData = resultSet.getMetaData();
    int numberOfColumns = metaData.getColumnCount();
    columnNames = new String[numberOfColumns];
    // Get the column names and cache them.
    // Then we can close the connection.
    for(int column = 0; column < numberOfColumns; column++) {
    columnNames[column] = metaData.getColumnLabel(column+1);
    // Get all rows.
    rows = new Vector();
    while (resultSet.next()) {
    Vector newRow = new Vector();
    for (int i = 1; i <= getColumnCount(); i++) {
         newRow.addElement(resultSet.getObject(i));
    rows.addElement(newRow);
    // close(); Need to copy the metaData, bug in jdbc:odbc driver.
    fireTableChanged(null); // Tell the listeners a new table has arrived.
    catch (SQLException ex) {
    System.err.println(ex);
    public void close() throws SQLException {
    System.out.println("Closing db connection");
    resultSet.close();
    statement.close();
    connection.close();
    protected void finalize() throws Throwable {
    close();
    super.finalize();
    // Implementation of the TableModel Interface
    // MetaData
    public String getColumnName(int column) {
    if (columnNames[column] != null) {
    return columnNames[column];
    } else {
    return "";
    public Class getColumnClass(int column) {
    int type;
    try {
    type = metaData.getColumnType(column+1);
    catch (SQLException e) {
    return super.getColumnClass(column);
    switch(type) {
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
    return String.class;
    case Types.BIT:
    return Boolean.class;
    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.INTEGER:
    return Integer.class;
    case Types.BIGINT:
    return Long.class;
    case Types.FLOAT:
    case Types.DOUBLE:
    return Double.class;
    case Types.DATE:
    return java.sql.Date.class;
    default:
    return Object.class;
    public boolean isCellEditable(int row, int column) {
    return true;
    public int getColumnCount() {
    return columnNames.length;
    // Data methods
    public int getRowCount() {
    return rows.size();
    public Object getValueAt(int aRow, int aColumn) {
    Vector row = (Vector)rows.elementAt(aRow);
    return row.elementAt(aColumn);
    public String dbRepresentation(int column, Object value) {
    int type;
    if (value == null) {
    return "null";
    try {
    type = metaData.getColumnType(column+1);
    catch (SQLException e) {
    return value.toString();
    switch(type) {
    case Types.INTEGER:
    case Types.DOUBLE:
    case Types.FLOAT:
    return value.toString();
    case Types.BIT:
    return ((Boolean)value).booleanValue() ? "true" : "false";
    case Types.DATE:
    return value.toString(); // This will need some conversion.
    default:
    return "'"+value.toString()+"'";
    public void setValueAt(Object value, int row, int column) {
    try {
    String tableName = metaData.getTableName(column+1);
    // Some of the drivers seem buggy, tableName should not be null.
    if (tableName == null) {
    System.out.println("Table name returned null.");
    String columnName = getColumnName(column);
    String query =
    "UPDATE "+tableName+
    " SET "+columnName+" = "+dbRepresentation(column, value)+
    " WHERE ";
    // We don't have a model of the schema so we don't know the
    // primary keys or which columns to lock on. To demonstrate
    // that editing is possible, we'll just lock on everything.
    for(int col = 0; col<getColumnCount(); col++) {
    String colName = getColumnName(col);
    if (colName.equals("")) {
    continue;
    if (col != 0) {
    query = query + " AND ";
    query = query + colName +" = "+
    dbRepresentation(col, getValueAt(row, col));
    System.out.println(query);
    statement.executeUpdate(query);
    catch (SQLException e) {
    //e.printStackTrace();
    System.err.println("Update failed");
    Vector dataRow = (Vector)rows.elementAt(row);
    dataRow.setElementAt(value, column);
    JScrollPane returnTabl()
    { return scrollPane;

    the setValueAt() method generate the SQL according to
    the selection on the JTable. The second update doesnt
    even generate any SQL query as it should always print
    it out in DOS even if update fails.there is only two possibilites remaining.
    1) there is a problem with the loop. seems unlikely.
    2) the setValueAt is not being called for some other reason.
    why don't you put some more lines to help you see what is happening.... some suggestions.
    uncomment the e.printStackTrace(); line
    put a System.out line at the start of the setValueAt method and through the iterations of the loop.

  • UPDATE statement in procedure

    Hi,
    I'm having trouble getting my SP to work. I've searched this forum for a similar post, but haven't found it.
    Can anyone please let me know what I'm doing wrong here?
    Thanks!
    CREATE OR REPLACE PROCEDURE updadminproc
    (pdate   IN CHANGE_CONTROL_ADMIN.CLOSEDATE%TYPE,
    pact   IN CHANGE_CONTROL_ADMIN.ACTIVE%TYPE,
    pstat1   IN CHANGE_CONTROL_ADMIN.STATUS1%TYPE,
    pstat2   IN CHANGE_CONTROL_ADMIN.STATUS2%TYPE,
    padmcomm   IN CHANGE_CONTROL_ADMIN.ADM_NOAPROVE%TYPE)
    (cctrlid IN NUMBER)
    IS
    BEGIN
      -- UPDATE STATEMENT
    UPDATE CHANGE_CONTROL_ADMIN
       SET CLOSEDATE = pdate, ACTIVE = pact, STATUS1 = pstat1, STATUS2 = pstat2, ADM_NOAPROVE = padmcomm
       WHERE CHANGE_CTRL_ID = cctrlid;
    COMMIT;
    END updadminproc;
    /Here are the errors I get that it's showing:
    LINE/COL ERROR
    7/2      PLS-00103: Encountered the symbol "(" when expecting one of the
             following:
             ; is with authid as cluster order using external
             deterministic parallel_enable pipelined
    8/2      PLS-00103: Encountered the symbol "IS" when expecting one of the
             following:
             returnMessage was edited by:
    user515689

    when I change it accordingly as to how you suggest, the procedure (in SQL Plus) gets created just fine, but then I get an Oracle error when calling the SP.
    PLS-00306: wrong number or types of arguments in call to 'UPDADMINPROC'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
            at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
            at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)Any ideas? Since it reads wrong no. of arguments?
    My Java call statement looks like the following:
    CallableStatement cstmt = connection.prepareCall("{call updadminproc (?,?,?,?,?)}");
       cstmt.setDate(1,cldt);
       cstmt.setInt(2,actboxval);
       cstmt.setString(3,status1);
       cstmt.setString(4,status2);
       cstmt.setString(5,fincomments);
       cstmt.executeUpdate();I mean, I'm not trying to update the ID no., just associate the record with the ID number (cctrlid).
    Thanks.
    Ok, I got it....even though not updating the ID # itself, I had to add it to the cstmt object.
    As in ....
    cstmt.setString(5,fincomments);
    cstmt.setInt(6,ctid2);
    cstmt.executeUpdate();
    Message was edited by:
    user515689

Maybe you are looking for