SQL Update COmmand in JSP

can i know the code syntax for updating my data in MySQL database wrtting in jsp page? i want to get value from the input user key in and update into my database.
thanks

i wan to get the value of String EmployeeID= request.getParameter("emp_id");
and String Password= request.getParameter("passwd"); to be check with my database..what shd i put at xxx and yyy..?
String EmployeeID= request.getParameter("emp_id");
String Password= request.getParameter("passwd");
Connection connLogin = null;
     Statement stLogin = null;
     ResultSet rsLogin = null;
try {
String url = "jdbc:mysql://localhost/cust";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
connLogin = DriverManager.getConnection(url);
stLogin = connLogin.createStatement();
rsLogin = stLogin.executeQuery("select Emp_ID from login_info where Emp_ID=xxx AND Passwd=yyy");
while(rsLogin.next()) {
%>
You have Succesfully Login
<jsp:include page="Action.html" flush="true"/>
<%
%>
<%
} catch (SQLException sqle) {
     out.println(sqle.getMessage());
//sqlException.printStackTrace();
%>
if i put rsLogin = stLogin.executeQuery("select Emp_ID from login_info where Emp_ID=EmployeeID AND Passwd=Password");, it wun work. what is teh coreect way to write?

Similar Messages

  • How can i write jstl with jsp in sql:update ,when it give sqlException"

    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql_rt"%>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
    <sql:query var="login" dataSource="jdbc:mysql://localhost/user,com.mysql.jdbc.Driver,user,parul">
    SELECT * FROM login;
    </sql:query>
    <html>
    <head>
    <title>login information</title>
    </head>
    <body>
    <h1>login information</h1>
    <table border="1">
    <tr>
    <th>id</th>
    <th>login</th>
    <th colspan="2">password</th>
    </tr>
    <c:forEach var="round" items="${login.rows}" >
    <tr>
    <td>${round.id}</td>
    <td>${round.login}</td>
    <td colspan="2">${round.password}</td>
    </tr>
    </c:forEach><tr>
    <form name="round-input" action="round_process.jsp" method="POST">
    <td><input name="id" type="text" size="20" /></td>
    <td><input name="login" type="text" size="20" /></td>
    <td><input name="password" type="text" size="20" /></td>
    <td><input type="submit" value="Update" /></td>
    </form>
    </tr>
    </table>
    </body>
    </html>
    it pass the parameter in round_process.jsp
    <!--
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql_rt" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
    -->
    <sql:query var="login" dataSource="jdbc:mysql://localhost/user,com.mysql.jdbc.Driver,user,parul">
    SELECT * FROM login WHERE id=?
    <sql:param value="${param.id}"/>
    </sql:query>
    <sql:update>
    INSERT INTO login(id,login,password)VALUES(?,?,?)
    <sql:param value="${param.id}"/>
    <sql:param value="${param.login}"/>
    <sql:param value="${param.password}"/>
    </sql:update>
    <c:redirect url="round-input.jsp"/>
    when i execute the second .jsp page it will show an exception and error that is
    javax.servlet.ServletException: Unable to get connection, DataSource invalid: "null"
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
         org.apache.jsp.round_005fprocess_jsp._jspService(round_005fprocess_jsp.java:87)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "null"
         org.apache.taglibs.standard.tag.common.sql.UpdateTagSupport.getConnection(UpdateTagSupport.java:234)
         org.apache.taglibs.standard.tag.common.sql.UpdateTagSupport.doStartTag(UpdateTagSupport.java:115)
         org.apache.jsp.round_005fprocess_jsp._jspx_meth_sql_update_0(round_005fprocess_jsp.java:168)
         org.apache.jsp.round_005fprocess_jsp._jspService(round_005fprocess_jsp.java:71)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.

    Your problem is that you need to have a
    <sql:setDataSource
           var="myDataSource"
           dataSource="jdbc:mysql://localhost/user,com.mysql.jdbc.Driver,user,parul"
    />and your sql:query would now be
    <sql:query var="login" dataSource="${myDataSource}">
    SELECT * FROM login;
    </sql:query>You can use whatever name you want for the var in the setDataSource as long as it matches the dataSource in the query.

  • HELP!!! Can't use sql:update in Netbeans Visual Web JSP

    I use Netbeans Visual Web in my project. I use Java DB database and Sun Java System Application Server 9.
    When i run my project, there is an error "The server encountered an internal error () that prevented it from fulfilling this request."
    Here is the codes:
    <?xml version="1.0" encoding="UTF-8"?>
    <jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:ui="http://www.sun.com/web/ui" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:sql="http://java.sun.com/jsp/jstl/sql" >
    <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
    <f:view>
    <ui:page binding="#{Page1.page1}" id="page1">
    <sql:update var="indata" dataSource="datasource">
    INSERT INTO "NBUSER"."user" ("Username") VALUES('jacky')
    </sql:update>
    <ui:html binding="#{Page1.html1}" id="html1">
    <ui:head binding="#{Page1.head1}" id="head1">
    <ui:link binding="#{Page1.link1}" id="link1" url="/resources/stylesheet.css"/>
    </ui:head>
    <ui:body binding="#{Page1.body1}" id="body1" style="-rave-layout: grid">
    <ui:form binding="#{Page1.form1}" id="form1"/>
    </ui:body>
    </ui:html>
    </ui:page>
    </f:view>
    </jsp:root>
    I can't store the data "jacky" into "Username" column in "user" table in database. Can anyone please let me know where is my mistake. Thanks.

    Maybe that SQL statement isn't valid. All those quotes look weird to me, but don't take that as meaning they are wrong. You should look in your server's logs to find out the actual error that occurred, rather than trying to guess what's wrong.

  • JSP sql:update how to commit.

    Can any body tell me how to do a commit in JSP. I am using the book JavaServer Pages book of O'relly
    as a frame work for a web page using JSP. Everything works great for select etc. However when I try to use examples with <sql:update Employee etc.... it seems that it works but when I look at the data base
    or do a <c:redirect> statement it doesn't seem to update the table. I am guessing that I need to do a commit before leaving my jsp page. Does any body know what can I do?
    Thanks
    Frank.

    what database are you using, Access?
    Try closing the statement and connection when your update is done.

  • SQL describe command not running in JSP

    Hello All,
    i hope u all will be enjoying ur lives :)
    i have a problem that when i run the SQL describe command it gives me the error that Invalid SQL Statement...
    the command syntax is
    desc tablename; OR describe tablename;
    and i am doing it like that
    ResultSet rs = stmt.executeQuery("describe CF");
    where CF is the name of table..
    actually what i want to do is get the columns and its datatypes dynamically.. means that i want i get all the tables first from database then whichever table i select i can display its records and also add delete and modify the records...
    if anyone have already code of this ..please email me at
    [email protected]
    i will be very very thank ful for that..
    otherwise tell me the solution of the above problem :(
    thanx in advance
    RANA

    You can get all the information about the table using the meta data. Run a dummy query (I don't think it even needs to return any results), and then grab the meta data
    from the result set:
    ResultSet rs = null;
    ResultSetMetaData rsmd;
    int numcolumns = 0;
    Vector field = new Vector();
    rs = statement.executeQuery( "select * from mytable where field='nevermatchme'");
    rsmd = rs.getMetaData();
    numcolumns = rsmd.getColumnCount();
    for ( int i = 1 ; i <= numcolumns ; i++ ) {
    field.add( rsmd.getColumnName(i) );
    You now have a Vector with one element per database field, each containing a String of that fields name. I believe it is also possible to get field
    type, etc also the MetaData.

  • Sql database connection in jsp

    Hi,
    I am new to java.
    I know how to connect the database in the java using the javacodings [jdbc] but i am don't know how to connect the database using the jsp.
    Is it easy. If so, can any one help me in this regards.
    Any sample codes or white paper available.
    thanks in advance,
    Regards,
    sa

    Hi,
    Here's a simple application i write to test JSTL.
    Using JSTL is easier.
    Create a directory named tests in your webapps tomcat directoty.
    In this, create a web-inf dir and inside a lib dir.
    Copy JSTL.JAR ans STANDARD.JAR in tests/web-inf/lib/ which are lib for JSTL (found on apache foundation web site, jakarta implementation).
    Copy you jdbc driver in jakarta-tomcat/common/lib dir.
    Here is a file to input some data from an HTML form:
    Create saisie.jsp and record.jsp in you tests apps dir.
    saisie.jsp:
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <html>
    <head>
    <title>Simple Example</title>
    </head>
    <body>
        <h1> Saisie de donn�es  </h1>
        <form name="saisie" action="record.jsp" method="get">
            Code :<input type="text" name="code"/>
            Text :<input type="text" name="text"/>
            <input type="submit" name="submit"/>
        </form>
    </body>
    </html>and record.jsp:
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <%@ page isELIgnored ="false" %>
    <html>
    <head>
    <title>Simple Example</title>
    </head>
    <body>
    <sql:query var="result"  maxRows="100">
         select * from ess
    </sql:query>
    <table>
         <!-- Affichage de l'ent�te avec le nom des colonnes -->
         <tr>
         <c:forEach var="name" items="${result.columnNames}">
              <th>${name}</th>
         </c:forEach>
         </tr>
         <!-- Affichage des donn�es avec 'rowsByIndex' -->
         <c:forEach var="ligne" items="${result.rowsByIndex}">
         <tr>
              <c:forEach var="valeur" items="${ligne}">
                   <td>${valeur}</td>
              </c:forEach>
         </tr>
         </c:forEach>
    </table>
    <c:set var="code_id" value="${param.code}"/>
    <sql:update>
        INSERT INTO ESS (ID,TEXT) VALUES (?,?)
        <sql:param>${param.code} </sql:param>
        <sql:param>${param.text}</sql:param>
    </sql:update>
    </body>
    </html>Here's web.xml file to create in tests/web-inf dir:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
        <description>Learning JSTL (or whatever you like</description>
        <context-param>
              <param-name>javax.servlet.jsp.jstl.sql.dataSource</param-name>
              <param-value>jdbc:postgresql://127.0.0.1/gihe,org.postgresql.Driver,gihe,****<param-value>
         </context-param> 
    </web-app>web.xml contains the datasource definition, the jdbc driver, the url, user and password.
    saisie.jsp is a standard html file.
    record.jsp use web.xml datasource to connect to the database and use JSTL tag to insert some data.
    more explanations on java sun site.

  • Update command in When-button-pressed.

    Hello OTN members,
    I have the following situation :
    Take an eg.
    There are two forms, the first form takes the fiedls such as EMP
    NAME, ADDRESS AND DEPT. This record generates a Empid from the
    sequence.
    The second form selects the empid from the LOV, and other fields
    such as Emp Salary, Commission and Bonus Rate(from the same
    table) are entered. When a Button is pressed, it should update
    the record with the above values where empid in the table is
    equal to the empid in this forms first field.
    I tried as below in when_button_pressed trigger::
    UPDATE EMP SET SALARY = :EMP_BLOCK.SALARY,
    COMMISSION = :EMP_BLOCK.COMMISSION etc
    where
    EMPID = :EMP_BLOCK.EMPID;
    The above statement does not update the record in the table.
    If there is any other approach for the above please suggest.
    Thanks in advance.
    Sailesh.
    null

    Hallo,
    you can check the number of updated row with the system variable
    SQL%ROWCOUNT. So if your where condition doesnt match any rows,
    no rows will be updated and also no error message will be
    generated. In this case SQL%ROWCOUNT contains 0 after the update
    command.
    other idea: make surte to commit your changes before querying
    the record from another sessuion!
    Sailesh (guest) wrote:
    : Hello OTN members,
    : I have the following situation :
    : Take an eg.
    : There are two forms, the first form takes the fiedls such as
    EMP
    : NAME, ADDRESS AND DEPT. This record generates a Empid from the
    : sequence.
    : The second form selects the empid from the LOV, and other
    fields
    : such as Emp Salary, Commission and Bonus Rate(from the same
    : table) are entered. When a Button is pressed, it should update
    : the record with the above values where empid in the table is
    : equal to the empid in this forms first field.
    : I tried as below in when_button_pressed trigger::
    : UPDATE EMP SET SALARY = :EMP_BLOCK.SALARY,
    : COMMISSION = :EMP_BLOCK.COMMISSION etc
    : where
    : EMPID = :EMP_BLOCK.EMPID;
    : The above statement does not update the record in the table.
    : If there is any other approach for the above please suggest.
    : Thanks in advance.
    : Sailesh.
    null

  • UPDATE command syntax for mulitple checkbox update

    Hi,
    I intend update the checkboxes by id in bulk.
    My table is below. I want to update the selected form_id
    checkboxe and their
    values accordingly. That, I click the checkboxes (containin
    form_id
    information) of 1, 3, and 6; and I check their respective
    fields for column
    check01 and check02.
    form_id check01 check02
    1 1 0
    2 0 1
    3 0 0
    4 1 1
    5 1 1
    6 1 0
    I am using below code for deleting. I can do insert into. But
    I could not
    figure out the correct syntax for UPDATE command similar to
    below example.
    Sample for deleting:
    DELETE FROM ADS
    WHERE AD_ID IN (varCheckBox)
    Thank you
    Hakan

    Check here for SQL UPDATE syntax..
    http://www.w3schools.com/sql/sql_update.asp
    Regards,
    ..Trent Pastrana
    www.fourlevel.com
    "Hakan834" <[email protected]> wrote in message
    news:e9tdd8$ppk$[email protected]..
    > Hi,
    >
    > I intend update the checkboxes by id in bulk.
    >
    > My table is below. I want to update the selected form_id
    checkboxe and
    > their values accordingly. That, I click the checkboxes
    (containin form_id
    > information) of 1, 3, and 6; and I check their
    respective fields for
    > column check01 and check02.
    >
    > form_id check01 check02
    > 1 1 0
    > 2 0 1
    > 3 0 0
    > 4 1 1
    > 5 1 1
    > 6 1 0
    >
    > I am using below code for deleting. I can do insert
    into. But I could not
    > figure out the correct syntax for UPDATE command similar
    to below example.
    >
    > Sample for deleting:
    > DELETE FROM ADS
    > WHERE AD_ID IN (varCheckBox)
    >
    >
    > Thank you
    >
    > Hakan
    >

  • Delete Command button doesn't take more than one parameter while update command does

    Hi,
    Does anybody have an idea WHY sharepoint does not send the parameter information to a delete command while the exact same parameter is being sent to the Update command?, the data is being pulled from an asp:TextBox bound  to the 'comments' field in
    the data source which happens to be the field I need to update, the code works for Update commands but not for Delete commands. Unfortunately I have to use sharepoint designer because SP is restricted at work, so I can't write code behind the scenes. I would
    appreciate any help, here's my code
    <%@ Page Language="C#" masterpagefile="../_catalogs/masterpage/v4.master" title="Test" inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" meta:progid="SharePoint.WebPartPage.Document" meta:webpartpageexpansion="full" %>
    <%@ Register tagprefix="SPSWC" namespace="Microsoft.SharePoint.Portal.WebControls" assembly="Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register tagprefix="cc2" namespace="Microsoft.SharePoint.WebControls" assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register tagprefix="WebUI" namespace="Microsoft.Office.InfoPath.Server.Controls.WebUI" assembly="Microsoft.Office.InfoPath.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register tagprefix="WebPartPages" namespace="Microsoft.SharePoint.WebPartPages" assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <asp:Content id="Content1" runat="server" contentplaceholderid="PlaceHolderMain">
    <asp:SqlDataSource runat="server" ProviderName="System.Data.SqlClient" UpdateCommand="sp_updateStartedApprovals" ID="SqlDataSource2" ConnectionString="Data Source=MCARLOSJ2;User ID=sa;Password=****;Initial Catalog=MyDB;" SelectCommand="SELECT * FROM mainView " __designer:customcommand="true" UpdateCommandType="StoredProcedure" DeleteCommand="sp_rejectApprovals" DeleteCommandType="StoredProcedure">
    <UpdateParameters>
    <asp:Parameter Name="comments" Type="String"/>
    <asp:parameter Name="id" Type="Int32" />
    </UpdateParameters>
    <DeleteParameters>
    <asp:Parameter Name="comments" Type="String"/>
    <asp:parameter Name="id" Type="Int32"/>
    </DeleteParameters>
    </asp:SqlDataSource>
    <asp:GridView runat="server" id="GridView1" AutoGenerateColumns="False" DataSourceID="SqlDataSource2" DataKeyNames="id" GridLines="None" ForeColor="#333333" CellPadding="4">
    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
    <Columns>
    <asp:boundfield DataField="description" HeaderText="Status" ReadOnly="True" SortExpression="description">
    </asp:boundfield>
    <asp:boundfield DataField="Employee Last Name" HeaderText="Employee Last Name" ReadOnly="True" SortExpression="Employee Last Name">
    </asp:boundfield>
    <asp:boundfield DataField="Employee First Name" HeaderText="Employee First Name" ReadOnly="True" SortExpression="Employee First Name">
    </asp:boundfield>
    <asp:boundfield DataField="Pending approval" HeaderText="Pending approval" ReadOnly="True" SortExpression="Pending approval">
    </asp:boundfield>
    <asp:boundfield DataField="Atnmt %" HeaderText="Atnmt %" ReadOnly="True" SortExpression="Atnmt %">
    </asp:boundfield>
    <asp:boundfield DataField="Country" HeaderText="Country" ReadOnly="True" SortExpression="Country">
    </asp:boundfield>
    <asp:boundfield DataField="comments" HeaderText="comments" ReadOnly="True" SortExpression="Comments">
    </asp:boundfield>
    <asp:boundfield DataField="processStartedDate" DataFormatString="{0:MM/dd/yyyy}" HeaderText="Date Opened" ReadOnly="True" SortExpression="processStartedDate">
    </asp:boundfield>
    <asp:boundfield DataField="Due Date" DataFormatString="{0:MM/dd/yyyy}" HeaderText="Due Date" ReadOnly="True" SortExpression="Due Date">
    </asp:boundfield>
    <asp:templatefield>
    <ItemTemplate>
    <asp:TextBox runat="server" id="comments" Text='<%# Bind("comments") %>'/>
    <asp:LinkButton runat="server" Text="Approve" id="Button1" CommandName="Update" CausesValidation="False" />
    <asp:LinkButton runat="server" Text="Reject" id="Button2" CommandName="Delete" CausesValidation="false"/>
    </ItemTemplate>
    </asp:templatefield>
    </Columns>
    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
    <PagerStyle HorizontalAlign="Center" BackColor="#284775" ForeColor="White" />
    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
    <EditRowStyle BackColor="#999999" />
    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    </asp:GridView>
    </asp:Content>

    Hi,
    you have multiple options here:
    1) upload as a script:
    a) save the statements in a file
    b) go to sql workshop > sql scripts
    c) upload script and run the script
    2) run the script line by line in the sql commands window directly:
    a) go to sql workshop > sql commands
    b) copy all statements there
    c) highlight the first statement with the mouse
    d) click "run" or press <ctrl>+enter
    3) use sql developer
    a) go to http://www.oracle.com/technology/products/database/sql_developer/index.html
    b) download and install
    c) connect to XE
    d) run the statements there
    Regards,
    ~Dietmar.

  • Statement SQL: UPDATE

    Hi all,
    can you insert into one Command a SELECT and in another Command an UPDATE?
    Thanks a lot

    Hi, I noticed this threat was still an open item; has there been a resolution as of yet? I have a similar situation...
    I need to add a value to a column if that value does not exist. I am fairly new to sql and was trying to use the Update command with the select statement (ex:
    SELECT "VW"."HE"
    FROM "AM_FACADE"."NM_OUTBOUND_SCHEDULE_BID_V" "VW"
    UPDATE "VW"
    SET "VW"."HE" = IN['1', '2', '3', '4', '5', '6', '7', '8', '9', '10' ,'11', '12','13','14','15','16','17','18','19','20','21','22','23','25','25']
    WHERE "VW"."HE" = IN['1', '2', '3', '4', '5', '6', '7', '8', '9', '10' ,'11', '12','13','14','15','16','17','18','19','20','21','22','23',"24"]
    Basically I want it to check the HE column to see if the 25th hour exist, if not add it.
    Any help would be appreciated.

  • Command Builder Update Command Algorithm

    Dear Sirs,
    When setting the update command of a sqldataadapter control, I use the following syntax :
     Dim cbsql As SqlCommandBuilder
        cbsql = New SqlCommandBuilder(dataadapter)
    The generated update command  is a syntax of parametric variables.
    I would like to know what algorithm does the command builder use to generate the updatecommand.

    Why do you want to know?
    It's been a while since I've seen a better and more detailed explanation than msdn
    https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommandbuilder(v=vs.110).aspx
    https://msdn.microsoft.com/en-us/library/tf579hcz(v=vs.110).aspx
    Loosely speaking you can think of it as taking each of the records that have changes and allocating the right command ready (to be applied later) for each of them.
    It looks at each record and decides if it's changed. Whether a record has been updated, added or deleted.
    If no command is provided, reflection is used (once) to build the sql for each of these.
    It  allocates the update sql to the updates, insert to the additions and update sql to the updates.
    The specific record to apply the change to is identified by primary key.  No primary key is a problem !
    If you wanted to take a look at the sql a command generated there are the various get... command methods.
    connection.Open();
    SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
    DataSet dataSet = new DataSet();
    adapter.Fill(dataSet, tableName);
    SqlCommand cmd = builder.GetUpdateCommand();
    string aSQLstring = cmd.CommandText;
    Hope that helps.
    Recent Technet articles:
    Property List Editing ;  
    Dynamic XAML

  • SQL UPDATE does not work

    Hey Guys,
    I have an update sql query which does not work with PreparedStatement object. Heres the code snippet:
    PreparedStatement pstmt;
    int numUpd;
    pstmt = con.prepareStatement(
    "UPDATE item_articles SET dataFile=? WHERE itemID=?");
    con.setAutoCommit(false);
    pstmt.setBinaryStream(1,fis,(int)file.length());
    pstmt.setInt(2,item.id);
    numUpd = pstmt.executeUpdate();
    con.commit();
    What I am doing here is that setBinaryStream(...) will upload a file into the DB. The query executes, theres no exception thrown, but my table shows empty field for the file. Note, there are no exceptions thrown from this query.
    If I do the same thing for an INSERT statement, it works. The file gets into the DB. So , the file is there on disk, and theres no problem with it. Just that it does not work with UPDATE.....any clues ???
    thanks
    Askar

    I think UPDATE commands dont work well with blobs.
    I use to select the register with a ResultSet, then get a BLOB Object from the column.
    So you can use a OutputStream to Upload your data.

  • Start SQL-Update query on click

    Hi,
    I would like to start in a JSP am JSTL-Update when the user clicks on a button.
    Unfortunately, I have not found any hint how to do that!
    Can someone give me some advise how this can be done?
    I have the following code:
    <sql:setDataSource dataSource="jdbc:oracle:thin:@<IP-address>:1521:<SID>,oracle.jdbc.driver.OracleDriver,<user>,<password>" var="datasource1"/>
    <sql:update var="insert1" sql="insert into table (column1,column2,column3,column4) select sysdate,column1,column2,column3 from <table2>" dataSource="${datasource1}"/>
    But I have no idea how to associate it with the click on a button.
    Best regards.

    What proportion of each column has a -1 value?
    Will the -1 value be in only one of the columns for each row or could there be multiple -1 values in a row?
    How big is the table?
    If only a small portion has a -1 and only one column per row could have -1, then seperate updates might be more efficient since only the columns that require updating will be touched. On the other hand, if several columns in a row could have -1 or if most rows would have at least one column with a -1, a single update might be more efficient since each row that requires multiple updates would only be touched once.
    John

  • AXL execute SQL update

    Is there a way to fire off an update query like:
    Update devices set description = 'A' where description = 'B'
    I get a "no update permission" error.
    Yes, this a bad idea for many reasons, but I'm not willing to let that stop me, at least in this lab/test scenario...

    Thanks for the response Stephan and s. Sorry - the original post had a typo. I was using the proper table name.
    I didn't realize that there was a command line option. I've been avoiding the command line because I don't know too much about it. The command line option worked:
    admin:run sql update device set description= "Test" where name="SEP000000032081"
    Rows: 1
    admin:
    Of course this morning, I get something totally different from AXL (but these are the actual reuest and response envelopes):
    sent:
    http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    update device set description= 'Test' where name='SEP001BD458B533'
    received:
    http://schemas.xmlsoap.org/soap/envelope/"
    SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    SOAP-ENV:Client
    Method only for queries
    http://www.cisco.com/AXL/API/1.0">
    -79750
    Method only for queries
    executeSQLQuery

  • Executing a DOS Command from JSP

    How do i execute a Dos command from within JSP. I would like to execute a sql Loader command .
    Thanks

    You use Runtime.execute().
    Take a look here for a few of the tricks involved in it:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

Maybe you are looking for

  • Indexes for group by query on table with 5million records

    Hi, Here is my query which is taking ages to run :      SELECT approved.budgetReferenceno                , approved.projects                , approved.allocations                , rptgen4                      , financialyear                , cashclas

  • Document url link on webdynpro iview

    Dear All We have developed  custom webdynpro ivew. Assigned that ivew to page and can display in ESS submenu. and one more km doc iview is there for document disply. But requirement is when enduser access webdynpro ivew  , in the same page there shou

  • Opening of new tab is set to specific website

    Hey, I downloaded some program the other day but removed it again. Yet my browser opens up my new tabs with the URL: http://newtab.certified-toolbar.com/nff/?si=41460&tid=592&new=true How do I change it back? I've just updated my browser to the lates

  • Macbook pro early 2011  stops working on normal boot up

    My mbp early 2011 with 4gb ram 500 gb hdd and intel core i7 processor 13" after installing yosemite seems to be sticking on normal boot but works in safe mode which I'm using now to put this discussion . Im a dj and need to use my computer by tmrw sa

  • Accounting doc. generation

    WHEN I AM DOING VF02 AND GENERATING ACCCOUNTING DOCUMENT GETTING ERROR THAT XXXXX GL IS BLOCKED . I WANT TO KNOW WHERE THIS SETTING HA BEEN DONE  AND HOW IT WORKS SO THAT I ACAN CHANGE THE GL OR TAKE CORRECTIVE ACTION. Please tell me how accounting d