Update Specific Rows In MySQL Database?

greetings all
i have MySQL database named library contains a table named books with the attributes:name,amount,price,cat_id
and i want to update all the names,amount,prices for specific cat_id
so i used the following query:
PreparedStatement ps = connection.prepareStatement("UPDATE books SET name = ?,amount = ?,price = ? Where cat_id = "+1);
and get the question marked values from the JTable named table_science
                for(int i = 0 ; i< dtm_science.getRowCount(); i++){                                         ps.setString(1,(String)table_science.getValueAt(i,2));                                  ps.setInt(2,(Integer)table_science.getValueAt(i,1));                 ps.setInt(3,(Integer)table_science.getValueAt(i,0));                                 ps.executeUpdate();                                                                                                                        }                         ps.close();             connection.close();
the code doesn't work properly
it takes the values in the last row in the jtable and set them for all attributes with cat_id=1
meaning if you have 3 rows in the jtable named table_science which have cat_id=1 and the columns:
name,amount,price
abc,5,300
efg,6,400
mno,6,900
and when i exceute the update query all the fields in the database which have cat_id=1 would be set to mno,6,900
meaning that the table_science would be:
mno,6,900
mno,6,900
mno,6,900
is there's an error in the code?
or what's the problem?
thanks in advance

the database name:test
table name:books
attributes:name,amount,price,cat_id
description:several names may have the same cat_id
goal:when the user presses update button
all names,amounts,prices with cat_id=1 in the database is updated with the JTable values name,amount,price
problem:when changing values in the JTable and trying to update all names,amounts,prices with cat_id=1 is set to the last row values in the jtable?
here's the whole code:
import javax.swing.*;
import javax.swing.table.*;
import java.awt.Dimension;
import java.awt.*;
import javax.swing.JFrame;
import java.awt.event.*;
import javax.swing.JTable;
import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSetMetaData;
import java.sql.ResultSet;
import java.sql.Statement;
class table_update extends JPanel {
    static DefaultTableModel dtm1;
    static JTable table1;
    static JFrame frame;
    public table_update() {
        super(new GridLayout(1, 1));
        dtm1 = new DefaultTableModel();
        dtm1.addColumn("ID");
        dtm1.addColumn("Name");
        dtm1.addColumn("Amount");
        dtm1.addColumn("Price");
        table1 = new JTable(dtm1) {
            public Class getColumnClass(int column) {
                return getValueAt(0, column).getClass();
        JScrollPane scrollPane1 = new JScrollPane(table1);
        JButton Update = new JButton("Update");
        table1.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
        table1.setPreferredScrollableViewportSize(new Dimension(410, 160));
        JPanel panel1 = new JPanel(new FlowLayout());
        panel1.add(scrollPane1);
        panel1.add(Update);
        Update.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event20) {
                update_db();
                frame.dispose();
                createAndShowGUI();
        //reading from databse
        try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection c1 = DriverManager.getConnection("jdbc:mysql://localhost/test", "root", "");
            Statement s1 = c1.createStatement();
            ResultSet rs1 = s1.executeQuery("SELECT name,amount,price from books where cat_id=1");
            int id1 = 0;
            while (rs1.next()) {
                id1++;
                Object[] obj = {id1, rs1.getString("name"), rs1.getInt("amount"), rs1.getInt("price")};
                dtm1.addRow(obj);
            c1.close();
        } catch (Exception e) {
            e.printStackTrace();
        table1.setModel(dtm1);
        setLayout(new BorderLayout());
        add(panel1, BorderLayout.CENTER);
    public static void createAndShowGUI() {
        frame = new JFrame("Update DB");
        frame.setSize(500, 300);
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(new table_update());
        frame.setResizable(false);
        frame.setVisible(true);
        JTable table1 = new JTable();
        table1.setModel(new DefaultTableModel(new Object[][][][]{}, new String[]{"id", "name", "amount", "price"}) {
            Class[] types = new Class[]{
                java.lang.Integer.class, java.lang.String.class, java.lang.Integer.class, java.lang.Integer.class
            public Class getColumnClass(int columnIndex) {
                return types[columnIndex];
    public static void update_db() {
        Connection c = null;
        PreparedStatement ps = null;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            String url = "jdbc:mysql://localhost:3306/test?requireSSL=false&useUnicode=true&characterEncoding=utf8";
            c = DriverManager.getConnection(url, "root", "");
            ps = c.prepareStatement("UPDATE books SET name = ?,amount = ?,price = ? WHERE cat_id = 1 ");
            for (int i = 0; i < dtm1.getRowCount(); i++) {
                ps.setString(1, (String) table1.getValueAt(i, 1));
                ps.setInt(2, (Integer) table1.getValueAt(i, 2));
                ps.setInt(3, (Integer) table1.getValueAt(i, 3));
                ps.executeUpdate();
            ps.close();
            c.close();
        } catch (Exception ex) {
            ex.printStackTrace();
    public static void main(String[] args) {
        createAndShowGUI();
}

Similar Messages

  • Updating a row in the DataBase

    HI all
    1>>I want to update the row which is edited in the form
    2>>So i am setting all the values in a bean class
    3>>I am opening the connection in the bussiness Logic class
    4>>I am writing the query for the updation of the row using the Match_ID which was which was filled at the time of the insertion of the data
    5>>When iam executing it (a)I am getting no errors nor on the browsing page nor on the Tomcat console
    6>>So if any one who can say where I might be going wrong
    in the bussiness Logic or BeanClass or Servlet Or jsp(form page) or Should i post my Code
    Thanks

    1>>I am Sending the value through the hidden field form to the servlet
    <form type="hidden" name="mid" value='<%=request.getAttribute("mid")%>'>-----------------------------------------------------------------------------------------------
    2>>Then in the servlet
    String idproof=req.getParameter("mid");
    int idp=Integer.parseInt(idproof);//parsing the  value
    User3 use3=new User3();// creating the bean object use3
    use3.setIdproof(idp);  //setting all the values in the bean class
    UserServices3 userServices3 = new UserServices3(); //also creating bussinesslogic class object
    userServices3.editMatch(use3);
    3>>Then in BussinessLogic Class
    public void editMatch(User3 user){
    User3 use3=user;
    int idProof=use3.getIdproof();
    ........//creating connection to the DataBase
    PeparedStatement ps=con.prepareStatement("UPDATE Match_Set set Match_ID=? , Team1=? , Team2=? , Odd1=? , Odd2=? , Start_date=? , End_Date=?  WHERE  Match_ID=? ");
    ps.setInt(1,ss);
    ps.setString(2,s2);
    ps.setString(3,s3);
    ps.setFloat(4,s4);
    ps.setFloat(5,s5);
    ps.setString(6,s6);
    ps.setString(7,s7);
    ps.setInt(8,idProof);
      int i=ps.executeUpdate();Message was edited by:
    saamer

  • Only updating specific rows.

    How do I only update certain rows in an AdvancedDataGrid - to avoid updating the whole thing.
    If it's any help, I want to update only the selected cells, or rows containing selected cells.  (allowMultipleSelection="true").
    One possible way is to convert selectedCells row and column values into references to the itemRenderer, and tell each itemRenderer to refresh.  But If there is a more direct way - I'll take it.  (Note that the documented AdvancedDataGrid.selectedItems property doesn't work).

    Hi,
    From your description, you have a list with Hyperlink/Picture column. When you change the Standard View to Datasheet View and perform bulk upload, the error occurs when there
    are .jpg files.
    I tried to reproduce via UI or code, all worked as expected.
    Can this error occur if you upload the .jpg files in Standard View?
    What if you upload one single .jpg file to this list in Datasheet View?
    If the issue still exists, I suggest you do the same test on another clean list in case it is a list issue.
    Feel free to reply with the test result if the issue still exists.             
    Best regards
    Patrick Liang
    TechNet Community Support

  • HELP! How te retrieve the last row in MYSQL database using Servlet!

    Hi ,
    I am new servlets. I am trying to retireve the last row id inserted using the servlet.
    Could someone show me a working sample code on how to retrieve the last record inserted?
    Thanks
    MY CODE
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class demo_gr extends HttpServlet {
    //***** Servlet access to data base
    public void doPost (HttpServletRequest req, HttpServletResponse resp)
         throws ServletException, IOException
         String url = "jdbc:mysql://sql2.njit.edu/ki3_proj";
              String param1 = req.getParameter("param1");
              PrintWriter out = resp.getWriter();
              resp.setContentType("text/html");
              String semail, sfname, slname, rfname, rlname, remail, message;
              int cardType;
              sfname = req.getParameter("sfname");
              slname = req.getParameter("slname");
              rfname = req.getParameter("rfname");
              rlname = req.getParameter("rlname");
              semail = req.getParameter("semail");
              remail = req.getParameter("remail");
              message = req.getParameter("message");
              //cardType = req.getParameter("cardType");
              cardType = Integer.parseInt(req.getParameter("cardType"));
              out.println(" param1 " + param1 + "\n");
         String query = "SELECT * FROM greeting_db "
    + "WHERE id =" + param1 + "";
              String query2 ="INSERT INTO greeting_db (sfname, slname ,semail , rfname , rlname , remail , message , cardType ,sentdate ,vieweddate) values('";
              query2 = query2 + sfname +"','"+ slname + "','"+ semail + "','"+ rfname + "','"+ rlname + "','"+ remail + "','"+ message + "','"+ cardType + "',NOW(),NOW())";
              //out.println(" query2 " + query2 + "\n");
              if (semail.equals("") || sfname.equals("") ||
              slname.equals("") || rfname.equals("") ||
              rlname.equals("") || remail.equals("") ||
              message.equals(""))
                        out.println("<h3> Please Click the back button and fill in <b>all</b> fields</h3>");
                        out.close();
                        return;
              String title = "Your Card Has Been Sent";
              out.println("<BODY>\n" +
    "<H1 ALIGN=CENTER>" + title + "</H1>\n" );
                   out.println("\n" +
    "\n" +
    " From  " + sfname + ", " + slname + "\n <br> To  "
                                            + rfname + ", " + rlname + "\n <br>Receiver Email  " + remail + "\n<br> Your Message "
                                            + message + "\n<br> <br> :");
                   if (cardType ==1)
                        out.println("<IMG SRC=/WEB-INF/images/bentley.jpg>");
                   else if(cardType ==2) {
                        out.println("<IMG SRC=/WEB-INF/images/Bugatti.jpg>");
                   else if(cardType ==3) {
                        out.println(" <IMG SRC=/WEB-INF/images/castle.jpg>");
    else if(cardType ==4) {
                        out.println(" <IMG SRC=/WEB-INF/images/motocross.jpg>");
    else if(cardType ==5) {
                        out.println(" <IMG SRC=/WEB-INF/images/Mustang.jpg>");
    else if(cardType ==6) {
                        out.println("<IMG SRC=/WEB-INF/images/Mustang.jpg>");
    out.println("</BODY></HTML>");
         try {
              Class.forName ("com.mysql.jdbc.Driver");
              Connection con = DriverManager.getConnection
              ( url, "*****", "******" );
    Statement stmt = con.createStatement ();
                   stmt.execute (query2);
                   //String query3 = "SELECT LAST_INSERT_ID()";
                   //ResultSet rs = stmt.executeQuery (query3);
                   //int questionID = rs.getInt(1);
                   System.out.println("Total rows:"+questionID);
    stmt.close();
    con.close();
    } // end try
    catch (SQLException ex) {
              //PrintWriter out = resp.getWriter();
         resp.setContentType("text/html");
              while (ex != null) { 
         out.println ("SQL Exception: " + ex.getMessage ());
         ex = ex.getNextException ();
    } // end while
    } // end catch SQLException
    catch (java.lang.Exception ex) {
         //PrintWriter out = resp.getWriter();
              resp.setContentType("text/html");     
              out.println ("Exception: " + ex.getMessage ());
    } // end doGet
    private void printResultSet ( HttpServletResponse resp, ResultSet rs )
    throws SQLException {
    try {
              PrintWriter out = resp.getWriter();
         out.println("<html>");
         out.println("<head><title>jbs jdbc/mysql servlet</title></head>");
         out.println("<body>");
         out.println("<center><font color=AA0000>");
         out.println("<table border='1'>");
         int numCols = rs.getMetaData().getColumnCount ();
    while ( rs.next() ) {
              out.println("<tr>");
         for (int i=1; i<=numCols; i++) {
    out.print("<td>" + rs.getString(i) + "</td>" );
    } // end for
    out.println("</tr>");
    } // end while
         out.println("</table>");
         out.println("</font></center>");
         out.println("</body>");
         out.println("</html>");
         out.close();
         } // end try
    catch ( IOException except) {
    } // end catch
    } // end returnHTML
    } // end jbsJDBCServlet

    I dont know what table names and fields you have but
    say you have a table called XYZ which has a primary
    key field called keyID.
    So in order to get the last row inserted, you could
    do something like
    Select *
    from XYZ
    where keyID = (Select MAX(keyID) from XYZ);
    Good Luckwhat gubloo said is correct ...But this is all in MS SQL Server I don't know the syntax and key words in MYSQL
    This works fine if the emp_id is incremental and of type integer
    Query:
    select      *
    from      employee e,  (select max(emp_id) as emp_id from employee) z
    where      e.emp_id = z.emp_id
    or
    select top 1 * from employee order by emp_id descUday

  • How to access specific row of a database table.

    hi all,
    i am saving all the hr tables in a internal table.
    say, mtable = 'pa0002'  is the content of mtable on looping above internal table.
    LOOP AT i_itf_list INTO wa_list.  "wa_list contains list of hr tables.
       mtable = wa_list-tabname.
       LOOP AT persno.  "persno contains list of personal numbers.
    "how to acess particular row of (mtable)  dynamically where pernr = persno-pernr."
       ENDLOOP.
    ENDLOOP.
    thanks.

    Hi,
    Use below code for your reference.
    data : ref_table_des type ref to cl_abap_structdescr,
              dref type ref to data.
    field-symbols : <itab> type standard table,
                            <wtab> type any.
    data : mtable type tabname.
    LOOP AT i_itf_list INTO wa_list. "wa_list contains list of hr tables.
    clear mtable.
    mtable = wa_list-tabname.
    LOOP AT persno. "persno contains list of personal numbers.
    ref_table_des ?= cl_abap_typedescr=>describe_by_name( mtable ).
    create data dref type handle ref_table_des.
    assign dref->* to <wtab>.
    create data dref like standard table of <wtab>.
    assign dref->* to <itab>.
    ***if you want to select multople rows use below select***********
    select * from (mtable)
    into table <itab>
    where pernr = persno-pernr.
    ********if you want to select single row use below select************
    select single * from (mtable)
    into <wtab>
    where pernr = persno-pernr.
    ENDLOOP.
    ENDLOOP.
    Vijay

  • Looping SelectedItem values in HttpService to Update Several Rows in Database in Flex

    Hi,
    My client wanted me to create something that allows certain
    DataGrid to display to allow users to edit and update the database
    records. The only dilemma I am having here is how to actually
    create something from Flex's end to allow users update several rows
    of the database at once. Since everything in my datagrid would be
    defined as selectedItem whenever a user accesses the entry, how can
    I get Flex to recognize each of the updated variables while I
    update the database?
    Another question is, if I do something like
    dg2.selectedItem.id, it would only display the "selectedItem," and
    since I intend to loop every single one of the values as such in
    the datagrid to be updated, is it possible to do something like dg.
    .id? I tried to do this, and I kept on getting errors.
    If anyone could refer me to some examples on how to get this
    to start, it would be great.
    Thanks in advance.
    Alice
    This is the current code I have:
    <mx:HTTPService id="save_scenario" method="POST" url="
    http://localhost/save_scenario.php"
    useProxy="false">
    <mx:request xmlns="">
    <scenario_name>{scenario_name}</scenario_name>
    <id_no>{dg2.selectedItem.id}</id_no>
    <region_name>{dg2.selectedItem.region_name}</region_name>
    <population>{dg2.selectedItem.population}</population>
    <market>{dg2.selectedItem.market}</market>
    </mx:request>
    </mx:HTTPService>

    Thanks, but I think I will be a little more explicit here
    about what I really wanted to know. My impression is that if I have
    a DataGrid and that I would like to allow users to edit certain
    entries within the actual grid and have all of it saved to the
    database, I could use a for loop and just update everything without
    paying attention to what has really been updated, but I have been
    struggling with how to pass it all to the variables side.
    Currently, I could update things one entry a time, by using the
    code I provided earlier, but is there a way of which I can have it
    all posted to the HTTPService in one go?
    Note: I tried using dg.
    .id_no in the for loop to iterate over the variables I intend to
    post, but I don't think I am allowed to do so, do I?
    Alice
    Attached is what I used in a PHP script to allow the code
    loop around the users' edits, how could I do the similar thing in
    Flex by assigning the index variable to something more dynamic?
    Attach Code
    <?php
    if(!isset($_POST['npop'])){
    // this is where the user will select how many pops to insert
    ?>
    <form method="post">
    <input type="text" name="npop" value="Type in how many
    post values">
    <input type="submit" value="Continue">
    </form>
    <?
    } else {
    if(!isset($_POST['pop'])){
    $pop = $_POST['npop'];
    // when the user has selected the N number of pops
    // its time to create the N input elements
    ?>
    <form method="post">
    <input type="hidden" name="npop"
    value="<?=$pop;?>">
    <input type="hidden" name="pop" value="0">
    <?
    for($i = 1;$i <= $pop; $i++){
    echo "<h3>Pop $i</h3>";
    // now comes the 5 input elements..
    // add them as u like naming them in the following pattern,
    // or whatever prefix
    ?>
    Market: <input type="text" name="a<?=$i;?>"
    value="0"><br />
    IM_accept: <input type="text" name="b<?=$i;?>"
    value="0"><br />
    IM_defer: <input type="text" name="c<?=$i;?>"
    value="0"/><br />
    CR_accept : <input type="text" name="d<?=$i;?>"
    value="0"><br />
    FC_accept : <input type="text" name="e<?=$i;?>"
    value="0"><br />
    <?
    ?>
    <input type="Submit" value="Submit form">
    </form>
    <?
    } else {
    $pop = $_POST['npop'];
    // when the user has submitted the pops,
    // they will be inserted to N rows in the table.
    for($i = 1; $i <= $pop; $i++){
    $a = $_POST['a'.$i]; $b = $_POST['b'.$i]; $c =
    $_POST['c'.$i];
    $d = $_POST['d'.$i]; $e = $_POST['e'.$i];
    $sql = "insert INTO table VALUES('$a', '$b', '$c', '$d',
    '$e')" . "\n";
    echo $sql;
    $myFile = "testFile.txt";
    $fh = fopen($myFile, 'a') or die("can't open file");
    fwrite($fh, $sql);
    fclose($fh);
    echo "POPs were recorded. Thank you";
    ?>

  • How to save values form all row in dynamic table into mysql database?

    hello guys..
    i got some problem on developing expert system using adobe dreamweaver and mysql.
    i've create a dynamic table and have some value from different row. i want to save values from all row to mysql database.. unfortunately.. i'm failed to do that.. for now, i just can save value from first row.
    kindly you can help me to solve this problem.. or maybe there is any tutorial i can follow..
    thank you in advance.
    this is my script for dynamic table
    <table border="1" cellpadding="1" cellspacing="1">
      <tr>
        <td>namaSoalan</td>
        <td>jaw</td>
      </tr>
      <?php do { ?>
        <tr>
          <td><?php echo $row_Recordset1['namaSoalan']; ?></td>
          <td><label for="9"></label>
            <select name="9" id="9">
              <option value="value" <?php if (!(strcmp("value", $row_Recordset1['namaSoalan']))) {echo "selected=\"selected\"";} ?>>sila</option>
              <option value="" <?php if (!(strcmp("", $row_Recordset1['namaSoalan']))) {echo "selected=\"selected\"";} ?>>ya</option>
              <option value="0" <?php if (!(strcmp(0, $row_Recordset1['namaSoalan']))) {echo "selected=\"selected\"";} ?>>tidak</option>
            </select>       
            <label for="u"></label></td>
        </tr>
        <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
    </table>

    dear bregent and SnakEyez02.
    i have create 2 table, which is soalan table and temporary table.
    user will answer all the question. either 'ya' or 'tidak'..
    each answer have different value..
    this value store permanently in soalan table..
    this value i want save to temporary table too.
    for now, i success only save for the first row but i want save for all..
    anybody please help me..

  • Multiple Rows Update / Refresh Toplink Query when database trigger involved

    Hi everybody!
    I have two easy troubles for you; the platform is the same as the SRDemo Toplink version.
    1.     Multiple Rows Update: I want to update with mergeEntity method, multiple rows for an isolated table; that method receives a parameter that I try to bind with the iterator "dataProvider" but it only merges the first row, not all, any other combination returns an error.
    What I want to do is to have a form (like tabular forms in Apex) that lets me update multiple rows in a single page. ¿May anyone tell me how to do it?
    2.     Refresh Toplink Named Query: I have a list on a page with two columns. From another page, a button does an action that fires a database trigger that updates one of the columns on the list´s page. When I go back to the list, it is not updated; however, the CacheResults´s property is set to false on the iterator.
    Thanks in advance,
    Alejandro T

    I didn't use it (yet), but - you might take a look. You'll find a [url http://www.oracle.com/technetwork/developer-tools/apex/application-express/apex-plug-ins-182042.html]Timer plug-in on this page. It is a dynamic action which allows you to periodically fire other dynamic actions in the browser. For example use the timer to refresh a region every five minutes. You can perform any dynamic action you want using this infrastructure.So I was thinking: you might use it to run a dynamic action which would check whether something changed in that table (I suppose you'll know the way) (for example, a database trigger might set a flag in some table, timestamp or similar), and - if you find that something really changed - refresh the page.
    As I said, I never used it so that's pure theory. Someone else might know better, though.

  • How to update transaction data automatically into MySQL database using PI

    Dear All,
    With reference to subject matter I want a sincere advice regarding how to update transaction data automatically into MySQL database using PI. Is there any link available where I can get step-by-step process.
    Ex: I have a MYSQL database in my organization. Whenever a delivery created in SAP some fields like DO Number, DO quantity, SO/STO number should get updated in MYSQL database automatically.
    This scenario is related to updation of transactional data into MYSQL DB and I want your suggestions pertaining to same issue.
    Thanks and Regards,
    Chandra Sekhar

    Hi .
    Develop a sceanrio between SAP to Database system,When the data updates in SAP Tables read the data and update it in DATA Base using JDBC adapter,but there will be some delay in updating data in MySQL.
    serach in sdn for IDOC-TOJDBC sceannario,many documents available for the same.
    Regards,
    Raja Sekhar

  • How to update single row of ms access database

    Hi All,
    can somebody tell me how can i edit/update a single row of ms access database?
    let say i want to edit the first row of the figure in the left. What i want is when i click in the row, it will pop up a window where i can edit the fields content. or may be is it possible to add a column with "edit" text which link to the appropriate row. so when i click the "edit" it will open the edit window.
    Thank you

    If you use a multi-column listbox indicator there is a "double-click" event that you can capture with an event structure. The event, when fired, returns the row that the user double-clicked. Use that parameter to fetch/modify the data as needed. Remember that to update the data in the database the table containing the data must have a primary key - or at lease something you can use to uniquely identify the rows.
    Remember that in a database, there is no such thing as "the first row"; you have to explicitly identify which row you wish to modify.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Update command overwrites 1st record in mysql database

    hi
    I'm having a bit of a problem with a form I created in livecycle designer.
    I have connected the form to a MySQL database.
    whenever I try to update a record , retrieved via navigation buttons or search box, the 1st record in the mysql database is overwritten.
    I'm using the xfa.sourceSet.DataConnection.update() with and an click event
    I have my Stay BOF and Stay EOF set on the data connections.
    I'm not sure what I am doing wrong.
    The forms Data connections are using sql select query because the table in the database has an auto incrementing column.
    any suggestions you guys provide will be appreciated.

    Guys, I am still racking my brain. I have taken some screenshots to show you how I have my database tables set up. I was able to get the tables over to the InnoDB type so I can make foreign keys. Here is how I currently have them setup, can someone check this out and see if it's correct?
    Table 1 (carinfo)
    Table 2 (images)
    Thanks

  • Mysql database "Invalid authorization specification:"

    Hi,
    we are using mysql database in our server. i ve created one database name and restored the data into that and i ve granted the all previliges for that user with one username and password. Now i ve written a java program to access that data base. and i am running that java program in server using one script. while i am running my java program in server. i am getting following exception message.
    Database: jdbc:mysql://ip. . . /xxxtesst
    user: xxxtest
    password: xxxtest
    <DbCall> doSomething Error 1: null
    java.sql.SQLException: Invalid authorization specification: Access denied for user 'xxxtest'@'app1.dmz.mysite.com' (using password: YES)
    java.sql.SQLException: Invalid authorization specification: Access denied for user 'xxxtest'@'app1.dmz.mysite.com' (using password: YES)
    at org.gjt.mm.mysql.MysqlIO.init(Ljava.lang.String;Ljava.lang.String;)V(Unknown Source)
    at org.gjt.mm.mysql.Connection.connectionInit(Ljava.lang.String;ILjava.util.Properties;Ljava.lang.String;Ljava.lang.String;Lorg.gjt.mm.mysql.Driver;)V(Unknown Source)
    at org.gjt.mm.mysql.jdbc2.Connection.connectionInit(Ljava.lang.String;ILjava.util.Properties;Ljava.lang.String;Ljava.lang.String;Lorg.gjt.mm.mysql.Driver;)V(Unknown Source)
    at org.gjt.mm.mysql.Driver.connect(Ljava.lang.String;Ljava.util.Properties;)Ljava.sql.Connection;(Unknown Source)
    at java.sql.DriverManager.getConnection(Ljava.lang.String;Ljava.util.Properties;Ljava.lang.ClassLoader;)Ljava.sql.Connection;(Unknown Source)
    at java.sql.DriverManager.getConnection(Ljava.lang.String;Ljava.lang.String;Ljava.lang.String;)Ljava.sql.Connection;(Unknown Source)
    at escrow.LandamDbremove.findnewrecords()V(LandamDbremove.java:205)
    at escrow.LandamDbremove.main([Ljava.lang.String;)V(LandamDbremove.java:761)
    Exception in Main : java.sql.SQLException: Invalid authorization specification: Access denied for user 'xxxtest'@'app1.dmz.mysite.com' (using password: YES)
    Note: i ve given currect username, password, database name in my program.

    When setting up users it is possible to restrict access by ip. You may have full priviledges as 'slai@localhost" but not as '[email protected]' . Check the user tables and see.

  • Updating a MySql database

    Hello everyone,
    I am trying to update a MySQL database using powershell.  Here is the code;
    $prodid=30
    [void][System.Reflection.Assembly]
    ::LoadWithPartialName("MySql.Data")
    $constring="server=localhost;uid=****;pwd=*****;database=random;Pooling=False"
    $mysql=New-ObjectMySql.Data.MySqlClient.MySqlConnection($constring)
    $mysql.Open()
    $command=$mysql.CreateCommand()
    $command.CommandText
    ="UPDATE
    products SET (products_status = 0) WHERE products_id like 30";
    $command.ExecuteNonQuery()
    $command.Dispose()
    $mysql.Close()
    what I get in return is the following error;
    ERROR: Exception calling "ExecuteNonQuery" with "0" argument(s): "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
    ERROR: version for the right syntax to use near '(products_status = 0) WHERE products_id like 30' at line 1"
    products_status is a TINYINT(1) value and products_id is a INT(11) value.  Now I know adding a NEW database entry with a field being an INT value you do not have single quotes or double quotes otherwise you'd get the same error.  So I thought UPDATING
    an existing record would follow the same rules, but NOPE it didn't work.  So then I tried single quotes and double quotes and still have the same results.
    Anyway, if someone knows how to update a TINYINT value from powershell, that would be great!  Thanks everyone.

    Hi NeoTrin,
    Thanks for your sharing =)

  • How to get data into the mySQL database?

    First some background.
    I have a website that has outgrown its designed dimensions and is a huge burden to maintain. See PPBM5 Benchmark
    There is a lot of maintenance work involved, so I'm investigating a PHP/MySQL approach to easen the burden and to add functionality to the site. With the current Excel based structure and over 420 entries, it is cumbersome for me to maintain, but also for users to find what they need.
    A MySQL based dynamic structure is a lot easier and offers vastly more selection capabilities, like selecting only records that meet specific criteria.
    Data submission is done with a form, that contains most of the relevant data, but the drawack is that people submitting their data are often not technically inclined, give wrong answers due to a lack of understanding or making typo's. The test results are attached in one or two separate .txt files, but often they have not read the instructions correctly or did something wrong, so these attached .txt files can not be trusted automatically, they have to be checked before inclusion.
    These were my initial thoughts:
    1. Data collection:
    To avoid spending all our energy and time  on correcting typo's, getting missing data, correcting errors, I am  investigating the use of CPU-Z in Ghost mode to create a .txt or .html  file that contains all relevant hardware info we need and even more. It gives all the info we currently have, but adds  data like number of memory sticks, DDR timings, stock clock speed and  BCLK setting, video card info and VRAM size, etc.
    To see what I mean, run CPU-Z, go to the About tab and press the Save Report button and look at the results.
    This can all be done without user intervention in an automatic way, but  maybe I need to add an Auto-It file to the test to make it all run as  desired.
    If this works and I'm able to extract the relevant data from the created  file and can insert it into the database, we may be in business for the  next version of PPBM5.5 or PPBM6. It does require a modification to the instructions, making them a lot  easier, because there is less data to fill out.
    2. Data submission:
    The submission form can be simplified if  the CPU-Z data can be used. We have to create an automatic way to attach  the created .html file from CPU-Z to the submission form and we have to  streamline the Output.txt and Output-MPE.txt files to be more easily included in the 'form.lib.php' file. It  currently is manual labor and very time consuming.
    3. Adding to Database:
    I have to find a way to create database  records from the Gmail forms I receive. All incoming mail messages need  to be checked on relevancy and if relevant, need to be added  automatically to the database and then offered for approval before final inclusion in the database. Data included in the database  will then include submission date and time, Email address,  IP address  used, plus links to the files submitted and available on the website.
    4. Publication of the database:
    After approval of new records from step  3, all updates will be automatically applied to the database and  accessible for users. I do not yet intend to introduce a user account ,  requesting login before all functionality is accessible. Too much trouble and administration.
    Queries should be possible on things like CPU (check box), so include  17-920, i7-930, i7-950 but exclude i7-980X and i7-990X, Size of memory  (check box), Overclocked (boolean, yes, no), SSD as OS disk, and similar  options.
    The biggest problem is to keep the color grading and statistical  indicators (Top, D9, Q3, Med, Q1 and D1) intact on dynamically generated  queries. Say you make a query which results in 20 observations, this  should show the related colors and legends. Next query results in 48 observations and of course the color grading and legends  do need to reflect that. Question in my mind, does the RPI remain  constant, independent of the query or does that need to be recalculated  on the basis of the query?
    Next thing is to allow a user to select a specific observation and by  simply clicking on it be shown, in a separate window (detail page) or  accordion, all the CPU-Z related information about the hardware.
    The graphs, Top-20 and MPE Gains, need to be dynamically adjusted, based on the query used.
    5. Ideally, external links:
    In an ideal situation, one could link the  CPU-Z data to external price databases, looking up current prices for  CPU, memory, video card, disks, raid controller, etc. to get instant  BFTB charts, based on the query made. But that is the next step.
    Situation now:
    I have a MySQL database that is easily updated with the new submissions. Simply create a .CSV flie from the submitted forms and import that into the database. The bulk of the initial work is done.Lots remain to be done as you can see above, but that is for a later time.
    Question:
    I have this table, that needs to be filled with data in the submitted and attached files. Mr. X submitted his data and can be uniquely identified by his "Ref_ID". He attached one or two files in .TXT format with the relevant test data. These files are stored on the server with a concatenated name:
    "Ref_ID","-","filename"
    Say his Ref-ID is: 20110204-6cf5 and his submitted file is called: Output(99).txt then the file can be found on the server as
    20110204-6cf5-Output(99).txt
    I need to be able to open that comma delimited file, the contents may look like this: "439","1036","819","531" and insert these contents into the relevant record and fields.
    Graphically,
    is what I want to achieve.
    This being my first exposure to PHP/MySQL, you can imagine I'm not clear on how to go from here.
    Added complication is that I actually have 5 numbers to insert per record and two calculated fields, Total Score and RPI should be calculated fields. Haven't yet figured out how to handle calculated fields, maybe only in the PHP/HTML code and not in the database.
    I hope someone can help me.

    You do have a very complex looking site and may need several tables in mysql to handle all that data. If you knew to phpmysql I would suggest taking a look at this tutorial it will help get you started in understanding how to $_GET info from a database and also how to $_POST data to a database. I am no expert just learning myself and I found this very helpful. This is the link http://www.adobe.com/devnet/dreamweaver/articles/first_dynamic_site_pt1.html
    There are also many tutorials on Youtube to help build a CMS Content Management Site I would suggest the following: -
    http://www.youtube.com/user/phpacademy
    http://www.youtube.com/user/betterphp
    http://www.youtube.com/user/flashbuilding
    And many more on my channel here
    http://www.youtube.com/user/Whisperingonthewind
    CMS's are easier to maintain, add edit and delete content.
    I have also recently bought a Book by David Powers Training from the Source very helpful.
    Anyway hope you get it sorted.

  • Update multiple rows in a dynamic table Dreamweaver CS5.5

    hello there
    i want to update multiple rows which comes from a dynamic table in Dreamweaver CS5 (a loop in php) here is my Mysql table :
    sql code
    CREATE TABLE `register`.`s_lessons` (
    `lid` int( 5 ) NOT NULL ,
    `sid` int( 9 ) NOT NULL ,
    `term` int( 5 ) NOT NULL ,
    `tid` int( 5 ) NOT NULL ,
    `point` double NOT NULL DEFAULT '0',
    PRIMARY KEY ( `lid` , `sid` , `term` ) ,
    KEY `tid` ( `tid` ) ,
    KEY `point` ( `point` )
    ) ENGINE = MYISAM DEFAULT CHARSET = utf8 COLLATE = utf8_persian_ci;
    and this is my page source code:
    php file
    <?php require_once('../Connections/register.php'); ?>
    <?php
    session_start();
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $colname1_rs1 = "-1";
    if (isset($_GET['term'])) {
      $colname1_rs1 = $_GET['term'];
    $colname_rs1 = "-1";
    if (isset($_GET['lid'])) {
      $colname_rs1 = $_GET['lid'];
    $colname2_rs1 = "-1";
    if (isset($_SESSION['tid'])) {
      $colname2_rs1 = $_SESSION['tid'];
    mysql_select_db($database_register, $register);
    $query_rs1 = sprintf("SELECT s_lessons.sid, s_lessons.lid, s_lessons.term, s_lessons.tid, s_lessons.point FROM s_lessons WHERE s_lessons.lid = %s AND s_lessons.term = %s AND s_lessons.tid  = %s", GetSQLValueString($colname_rs1, "int"),GetSQLValueString($colname1_rs1, "int"),GetSQLValueString($colname2_rs1, "int"));
    $rs1 = mysql_query($query_rs1, $register) or die(mysql_error());
    $row_rs1 = mysql_fetch_assoc($rs1);
    $totalRows_rs1 = mysql_num_rows($rs1);
    $count=mysql_num_rows($rs1);
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    for ($j = 0, $len = count($_POST['lid']); $j < $len; $j++) {
    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
      $updateSQL = sprintf("UPDATE s_lessons SET point=%s WHERE tid=%s, lid=%s, sid=%s, term=%s",
                           GetSQLValueString($_POST['point'] [$j], "double"),
                                GetSQLValueString($_SESSION['tid'], "int"),
                           GetSQLValueString($_POST['lid'] [$j], "int"),
                                GetSQLValueString($_POST['sid'] [$j], "int"),
                                GetSQLValueString($_POST['term'] [$j], "int"));
      mysql_select_db($database_register, $register);
      $Result1 = mysql_query($updateSQL, $register) or die(mysql_error());
      $updateGoTo = "student_lists.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $updateGoTo));
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>r</title>
    <link href="styles/style.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="styles/in_styles.css" rel="stylesheet" type="text/css" media="screen" />
    </head>
    <body>
    <div id="wrapper">
         <div id="header-wrapper">
         </div>
         <!-- end #header -->
         <div id="page">
              <div id="page-bgtop">
                   <div id="page-bgbtm">
                        <div id="content">
                             <div class="post">
                               <div style="clear: both;">
                            <form name="form1" id="form1" method="post" action="<?php echo $editFormAction; ?>">
                            <table border="1" align="center">
                              <tr>
                                <th>Student ID</th>
                                <th>Lesson ID</th>
                                <th>Semester</th>
                                <th>Point</th>
                              </tr>
                              <?php do { ?>
                                <tr>
                                  <td class="data"><label for="sid[]"></label>
                                  <input name="sid[]" type="text" id="sid[]" value="<?php echo $row_rs1['sid']; ?>" size="9" readonly="readonly" /></td>
                                  <td class="data"><label for="lid[]"></label>
                                  <input name="lid[]" type="text" id="lid[]" value="<?php echo $row_rs1['lid']; ?>" size="5" readonly="readonly" /></td>
                                  <td class="data"><label for="term[]"></label>
                                  <input name="term[]" type="text" id="term[]" value="<?php echo $row_rs1['term']; ?>" size="4" readonly="readonly" /></td>
                                  <td><label for="point[]"></label>
                                    <input name="point[]" type="text" id="point[]" value="<?php echo $row_rs1['point']; ?>" size="4" />                             
                              </tr>
                                <?php } while ($row_rs1 = mysql_fetch_assoc($rs1)); ?>
                            </table>
                            <p>
                              <input type="submit" name="Submit" id="Submit" value="Submit" />
                              <input type="hidden" name="MM_update" value="form1" />
                            </p>
                            </form>
                               </div>
                             </div>
                        <div style="clear: both;">
                    </div>
                        </div>
                        <!-- end #content -->
                        <!-- end #sidebar -->
                        <div style="clear: both;"> </div>
                   </div>
              </div>
         </div>
         <!-- end #page -->
    </div>
    <!-- end #footer -->
    </body>
    </html>
    <?php
    mysql_free_result($rs1);
    ?>
    All i want is that when users click on SUBMIT button values of point column in s_lessons(database table) be updated by new entries from user.
    i did my best and result with that code is :
    You  have an error in your SQL syntax; check the manual that corresponds to  your MySQL server version for the right syntax to use near ' lid=888,  sid=860935422, term=902' at line 1
    I would appreciate any idea.
    with prior thanks

    Go to the Row Properties, and in the Visibility tab, you have "Show or hide based on an expression". You can use this to write an expression that resolves to true if the row should be hidden, false otherwise.
    Additionally, in the Matrix properties you should take a look at the filters section, perhaps you can achieve what you wish to achieve through there by removing the unnecessary rows instead of just hiding them.
    It's only so much I can help you with the limited information. If you require further help, please provide us with more information such as what data are you displaying, what's the criteria to hiding rows, etc...
    Regards
    Andrew Borg Cardona

Maybe you are looking for

  • Verification of Digital Signatures

    Hi... I would like to know, how does a process from a LiveCycle authenticates the Digital signatures? I need the clarification on the steps followed. I mean, how does the process interacts with Trust Store and what it looks up there. Will it check fo

  • R/3 transactions(BAPI) with webdynpro

    Hi, A client wants to have some R/3 transactions represented in the portal.It is about the transactions ME51,ME52,ME53(purchase requisition). They don't have ITS server. So Iviews need to be created with webdynpro. I know about some standaard SAP Ivi

  • How use the pager tag library for multi pagin

    hi, in fact i be new in the Jsp World so i want to use the multi pagin in my jsp can you help me. best regards

  • Need to fetch only the select statement

    Hi , I am able to fetch all the select statements from my program if program name as my input. I want only the select statement where we fetch the field entries like select single from mara select * from mara select count(*) select matnr from mara li

  • How to read specific value in XML using AppleScript?

    I have a XML file which I get from Mediainfo, and I want to get the value of Format of the Audio Track from it (In this case, ALAC) using AppleScript. Could anybody help me with this? Thanks. <?xml version="1.0" encoding="UTF-8"?> <Mediainfo version=