Comparing the data in MySql

Hi,
I got a problem which i stuck in.Here how it goes:
i entered the data in MySql database as shown below
movieid movietitle cinema
1 signs apple
2 signs pear
3 signs orange
4 ET pear
5 ET orange
I got a main page in which user can select his choice of movie (signs,ET) from radio buttons and his choice of cinema from drop boxes.
Now here's the problem, when user choose his movie title and cinema, how do i check whether his choice of movie is availiable in the cinema. Coz some movies in not avail. in particular cinema (ex. ET not avail in apple).I need to display the output on next page.
As a newbie in jsp, i am not familiar on how to start the coding. If anyone knws, pls tell me how to go about doing.If possible, can show me codes on how to compare string with data in database.
Thanx for your time in looking in this prob.I greatly appreciate it ^.^
-miN

You can make the following query on the result page:
"select * from the_table where movietitle = ? and cinema = ?"
then you set movietitle and cinema to those which the user selected. If the resultset contains more than 0 rows, that means the movie is available.
Below is the sample code, it assumes you have a connection to the database:
PreparedStatement stat = myConnection.prepareStatement("select * from the_table where movietitle = ? and cinema = ?");
stat.setString(1, usersMovieTitleSelection);
stat.setString(2, usersCinemaSelection);
ResultSet res = stat.executeQuery();
if (res.next()) {
out.print("The movie is available");
} else {
out.print("The movie is not available");
}Now just add that to your JSP page. Enjoy ! =)

Similar Messages

  • Strange scenario,Oracle can not display the data in mysql correctly

    I use Heterogeneous Service+ODBC to achieve "oracle access mysql"(any other method?),and now i find Oracle can not display the data in mysql correctly:
    -------mysql------------
    mysql> create table tst(id int,name varchar(10));
    Query OK, 0 rows affected (0.00 sec)
    mysql> insert into tst values(1,'a');
    Query OK, 1 row affected (0.00 sec)
    mysql> select * from tst;
    ------------+
    | id | name |
    ------------+
    | 1 | a |
    ------------+
    1 row in set (0.00 sec)
    mysql> show create table tst\G
    *************************** 1. row ***************************
    Table: tst
    Create Table: CREATE TABLE `tst` (
    `id` int(11) DEFAULT NULL,
    `name` varchar(10) DEFAULT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8
    1 row in set (0.00 sec)
    -------------oracle ------------------
    SQL> select count(*) from "tst"@mysql;
    COUNT(*)
    49
    SQL> select * from "tst"@mysql;
    id
    1
    SQL> desc "tst"@mysql;
    Name Null? Type
    id NUMBER(10)

    You can make the following query on the result page:
    "select * from the_table where movietitle = ? and cinema = ?"
    then you set movietitle and cinema to those which the user selected. If the resultset contains more than 0 rows, that means the movie is available.
    Below is the sample code, it assumes you have a connection to the database:
    PreparedStatement stat = myConnection.prepareStatement("select * from the_table where movietitle = ? and cinema = ?");
    stat.setString(1, usersMovieTitleSelection);
    stat.setString(2, usersCinemaSelection);
    ResultSet res = stat.executeQuery();
    if (res.next()) {
    out.print("The movie is available");
    } else {
    out.print("The movie is not available");
    }Now just add that to your JSP page. Enjoy ! =)

  • How to get the data from mysql database which is being accessed by a PHP application and process the data locally in adobe air application and finally commit the changes back in to mysql database through the PHP application.

    How to get the data from mysql database which is being accessed by a PHP application and process the data locally in adobe air application and finally commit the changes back in to mysql database through the PHP application.

    If the data is on a remote server (for example, PHP running on a web server, talking to a MySQL server) then you do this in an AIR application the same way you would do it with any Flex application (or ajax application, if you're building your AIR app in HTML/JS).
    That's a broad answer, but in fact there are lots of ways to communicate between Flex and PHP. The most common and best in most cases is to use AMFPHP (http://amfphp.org/) or the new ZEND AMF support in the Zend Framework.
    This page is a good starting point for learning about Flex and PHP communication:
    http://www.adobe.com/devnet/flex/flex_php.html
    Also, in Flash Builder 4 they've added a lot of remote-data-connection functionality, including a lot that's designed for PHP. Take a look at the Flash Builder 4 public beta for more on that: http://labs.adobe.com/technologies/flashbuilder4/

  • UDF to compare the dates with the input date

    Hi,
    Help me in writing an UDF to compare the input date with start date and end date.
    I had written following UDF, but it is not working. we are on XI 3.0
    try {
                SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
                Date sd = df.parse(StartDate);
                Date id = df.parse(InputDate);
                Date ed = df.parse(EndDate);
                if ((sd.before(id) || (sd.equals(id))) && (ed.after(id)) || (ed.equals(id))) {
              return true;               
    else{
                    return false;
            }     catch (Exception e){
           e.printStackTrace();
    Thanks
    Srinivas

    Hello Srinivas,
    did you import this two classes in your UDF ?  java.text.* and java.util.*
    In case you did but the program is still not working I just wrote a code without imports. See if this might help. I have tested this with all type of data please test again from your end. I have assumed that if three dates are equal the function return true. I am not sure whether you wanted to exclude the boundary dates. In case you want to exclude those dates just replace '<=' with '<' symbol. The code could have been smarter but in short time I thought this might help.
    public class DateRange {
      static boolean compareDate(String startDate,String inputDate,String endDate)
              int j,k,l;
              String s[],i[],e[];          
              s=startDate.split("-", 3);
              i=inputDate.split("-", 3);
              e=endDate.split("-", 3);
              j=s[0].compareTo(i[0]);
              k=i[0].compareTo(e[0]);
              l=s[0].compareTo(e[0]);
              if(l>0|| j>0 || k>0)
                   return false;
              if(j<=0 && k<0)
                   return true;
              j=s[1].compareTo(i[1]);
              k=i[1].compareTo(e[1]);
              l=s[1].compareTo(e[1]);
              if(l>0|| j>0 || k>0)
                   return false;
              if(j<=0 && k<0)
                   return true;
              j=s[2].compareTo(i[2]);
              k=i[2].compareTo(e[2]);
              l=s[2].compareTo(e[2]);
              if(l>0|| j>0 || k>0)
                   return false;
              if(j<=0 && k<=0) 
                   return true;
                return false;
         public static void main(String[] args) {
              String startDate="1992-04-03";
              String inputDate="1992-02-03";
              String endDate="1992-02-03";
              System.out.println(compareDate(startDate,inputDate,endDate));
    Plese let me know if this works.
    regards
    Anupam

  • PostChanges()  commit the data into MySQL with engine=MyISAM

    suddenly i found the following code called in AM could commit the change into database .
    this.getTransaction().postChanges();
    My database is MySQL 5.0,and set it with MyISAM engine .i know this engine can not support transaction.

    Hi,
    In the same step 4, please try the option pure SQL and enter the query, "select count(*) from tablename"
    Please check whether this is working fine ? And also, were you able to see the records in the JDeveloper IDE with the connecting to the MySQL Database...
    And aslo, the data source you have created for accessing the mySQL Database in weblogic console, what username credentials have you given ? please check whether that username has privileges to the table you want to select ? And , the table you are selecting is under the same username schema or another schema ? If it is a different schema , then find out whether the username you have given while creating the data source has read/write privileges to that table ?
    Thanks,
    N

  • How to compare the date value with the date datatype column?

    Hi,
    I am executed a query to get output for the particular date in two different database.
    I got output in one db environment, but in the another environment i didnt get the output.
    APP_DECISION_DATE column contains date datatype
    ex:
    SQL> select DECISIONED_STAGE_ID,DECISIONED_STAGE_USER_ID from naap10_application where APP_DECISION_DATE = TO_DATE('23-JAN-07',
    'DD-MON-YY'); 2
    DECISIONED_STAGE_ID DECISIONED_STAG
    2006060106 SYSTEM
    DATABASE - II
    SQL> select DECISIONED_STAGE_ID,DECISIONED_STAGE_USER_ID from naap10_application where APP_DECISION_DATE=
    TO_DATE('31-JAN-2007','DD-MON-RRRR') and application_id=2007010028552;
    no rows selected
    in the same db i got the output while i used the TO_DATE(APP_DECISION_DATE)
    SQL> select DECISIONED_STAGE_ID,DECISIONED_STAGE_USER_ID from naap10_application where TO_DATE(APP_DECISION_DATE)=
    TO_DATE('31-JAN-2007','DD-MON-YYYY') and application_id=2007010028552; 2
    DECISIONED_STAGE_ID DECISIONED_STAG
    2006060113 SYSTEM
    is it necessary to use TO_DATE function while i am using the data datatype column in the WHERE CLAUSE?
    Thanks in advance.
    siva

    Sorry & thanks sathish,
    Now i got the result.
    SQL> select DECISIONED_STAGE_ID,DECISIONED_STAGE_USER_ID from naap10_application where APP_DECISION_DATE BETWEEN TO_DATE ('31.01.2007 00:00:00', 'DD.MM.YYYY HH24:MI:SS') AND TO_DATE ('31.01.2007 23:59:59', 'DD.MM.YYYY HH24:MI:SS')
    2 and application_id=2007010028552;
    DECISIONED_STAGE_ID DECISIONED_STAG
    2006060113 SYSTEM
    ================================
    But one doubt,
    When i created the column with the date datatype how it gets the time value,
    And in one environment db i got the result but in another environment i dont get,
    Shall i want to change any session status of date?

  • Howto: compare the data key in and data from rowSetInfo

    how to manually retrive the data from the rowSetInfo. I am using the command
    rowSetInfo1.getAttribute().toString();
    but it doesn't work. Pls help !!

    Loo, in addition to Vladimir suggestion, try following too. It works for me.
    Import javax.infobus.*;
    Try{
    ScrollableRowsetAccess my_Rs = ((ScrollableRowSetAccess)myRowSetInfo.getRowSetAccess();
    ImmediateAccess ia = (ImmediateAccess)my_Rs.getColumnItem("COL_NAME");
    String str = ia.getValueAsString();
    //now str is available to test
    }catch(Exception e){
    null

  • How to compare the data in a highscore file(.txt)  for a game?

    As mention above,i would like to check the highscore everytime the game has finished,and updates it, what classes should be used? FileReader, FileWriter, or Properties? If so, how the codes is likely to be? Thanks a lot.

    I would discourage you from using a plain old text file to save your high scores in. The obvious reason being is that your little brother can just edit the file in notepad, then run to you and taunt, "I've got the highest score, nyah nyah nyah!"
    If you must do it, I would use PrintWriter and simply print out each line as needed. Reading the lines back into the game is only a tad more difficult, but you can simply read in each line as a String, and store each String in an array, or a Vector if you don't know how many high scores you will have.
    In the long run, you should create a serializable object that contains either the Vector or the Array of scores and instruct the object to save itself or load itself as needed. This is essentially how Properties work except you have more control over the internal data format.
    On second thought, Properties would work just fine, but you cannot guarantee that the scores will be saved in a particular order - you would have to add an additional routine to read in each Property (specifically, each name/score pair) and then sort them. Once you do that, there's no real difference between a Properties file and rolling your own Serializable array.

  • How to compare the data in a view with data present in a master data?

    Hi All,
    We have loaded some data into a Master Data Object (YMETADATA) in Development system.
    Now, the same data can be present in a view RSDVCHA.
    Our aim is to write a ABAP program, which would read a record from RSDVCHA and look into Master Data records and show whether it is present in the master data or not?
    Has anyone written such type of code earlier, If so, please do help me out in writing this code?
    Thanks in advance,
    Anjum.

    Hello Anjum,  
    It looks that the view is based on the master data table itself and view doesn't contain data and is a logical representation of the underlying database tables.
    Moreover the view RSDVCHA is used for viewing the  characteristics, basic chars and local properties.
    Are you storing similar values in YMETADATA?
    [Thanks|http://chandranonline.blogspot.com/]
    [Chandran|http://chandranonline.blogspot.com/]

  • Comparing the Dates and Exclude the Dates with Blank one in BEx Query

    Hi all,
        I have created the Formula Variables ZFV_DATE1 on ZDATE1, ZFV_DATE2 on ZDATE2,
           Calculated KF ZCKF_Date with 'ZV_DATE1 <  ZV_DATE2' and
           Restricted KF ZRKF_DATE on Key Figure ZCKF_DATE & Characteristic ZDELETE = 'X' to find the Count.
    I should exclude if any ZDATE1 or ZDATE2 is Blank in the report. So I kept ZDATE1 & ZDATE2 with Exclude when it is Blank in Filter Section. It is excluding globally all Blank ZDATE1 & ZDATE2, but the Calculated KF logic 'ZV_DATE1 <  ZV_DATE2' is not working. It has 'ZV_DATE1 > ZV_DATE2' records also. Next I moved ZDATE1 & ZDATE2 to Restricted KF ZRKF_DATE to Exclude the Blank dates and the report doesn't show correct results. How could I get the correct results with 'ZV_DATE1 < ZV_DATE2' and any ZDATE1 or ZDATE2 is not Blank.
    Thanks,
    Venkat.

    In that case, you approach seems to be mor or less correct. Restrcit the report using Filters on ZDATE1 and ZDATE2 not equal to Blank. You have mentioned that you have defined the CKF as 'ZFV_DATE1 < ZFV_DATE2'. i am assuming you have used boolean operator here. In this case it would  result in '1' when the condition is true (i.e, when ZFVDATE2 is greater than ZFVDATE1), else it will result in a '0'. Now, in your report, you should create a condition where you only keep the records where this CKF, ZCKF_Date = 1. This would filter out all the ZCKF=0 records, and hence only thiose records with ZFV_DATE1 < ZFV_DATE2 would be shown.
    Regards,
    Satwik

  • How to compare the date in  filter.......

    Hi,
    I want to put the filter on the expiration date in Free characteristics.  I need all the stock for which the expiration date is less than or equal to the current date.
    I guess I need to create a variable for this , any suggestions ?
    Thanks , Jeetu

    Hi Jeetu,
    you could just create a variable on the experation date. In the selection window choose selection 'Value range' and choose in the listbox next to it 'Less than or equal'. Now drag the variable 'Current calendar day' into the Selection box.
    This should do the trick.
    regards,
    Raymond Baggen
    Uphantis bv

  • How to compare the data of two identical tables

    My requirement is to compare two identical tables(eg., t1 and t2) and display the column, which value got changed, old value and its new value.
    For eg:
    T1:
    StudId C1 C2 C3
    1 40 50 90
    2 30 80 100
    3 20 10 11
    T2:
    StudId C1 C2 C3
    1 100 60 90
    2 30 90 100
    3 20 60 80
    output should be:
    StudId Column prevvalue changedvalue
    1 C1 40 100
    1 C2 50 60
    2 C2 80 90
    3 C2 10 60
    3 C3 11 80
    Please help me to how to achieve using oracle pl/sql. It is bit urgent

    No need of PL/SQL, you can do it in SQL as shown
    SQL> create table t1
      2  (
      3  studentId number,
      4  c1 number,
      5  c2 number,
      6  c3 number
      7  );
    Table created
    SQL> insert into t1 values (1,40,50,90);
    1 row inserted
    SQL> insert into t1 values (2,30,80,100);
    1 row inserted
    SQL> insert into t1 values (3,20,10,11);
    1 row inserted
    SQL> commit;
    Commit complete
    SQL> create table t2
      2  (
      3  studentId number,
      4  c1 number,
      5  c2 number,
      6  c3 number
      7  );
    Table created
    SQL> insert into t2 values (1,100,60,90);
    1 row inserted
    SQL> insert into t2 values (2,30,90,100);
    1 row inserted
    SQL> insert into t2 values (3,20,60,80);
    1 row inserted
    SQL> commit;
    Commit complete
    SQL> select * from t1;
    STUDENTID         C1         C2         C3
             1         40         50         90
             2         30         80        100
             3         20         10         11
    SQL> select * from t2;
    STUDENTID         C1         C2         C3
             1        100         60         90
             2         30         90        100
             3         20         60         80
    SQL> select
      2  t1.studentId StudId,'c1' ColumnName,t1.c1 prevvalue,t2.c1 changedvalue
      3  from t1,t2
      4  where t1.studentId = t2.studentId and
      5  t1.c1 <> t2.c1
      6  union
      7  select
      8  t1.studentId,'c2',t1.c2,t2.c2
      9  from t1,t2
    10  where t1.studentId = t2.studentId and
    11  t1.c2 <> t2.c2
    12  union
    13  select
    14  t1.studentId,'c3',t1.c3,t2.c3
    15  from t1,t2
    16  where t1.studentId = t2.studentId and
    17  t1.c3 <> t2.c3
    18  ;
        STUDID COLUMNNAME  PREVVALUE CHANGEDVALUE
             1 c1                 40          100
             1 c2                 50           60
             2 c2                 80           90
             3 c2                 10           60
             3 c3                 11           80
    SQL>

  • How to read the data from an excel file into MYSQL by java language

    Hi all,
    I have some data in excel spread sheet and I want to put the data into MYSQL data base. I created the tables in MYSQL> How can I write a program in JAVA that puts the value from excel sheet to mysql??
    I would appreciate your help
    regards

    By typing code at the keyboard... but presumably you meant to ask what code you should type.
    To get data out of Excel there are a few alternatives. The Google keywords I would use to find them are "java excel". I use Apache POI but there are other possibilities, I believe. As for getting the data into MySQL once you have extracted it from Excel, you would use JDBC. But you already knew that, didn't you? You did find the JDBC forum.
    In general it's better to ask a specific question on a forum. If you don't have a clue (which is the way we all start out) then just telling people that isn't going to be helpful. The best you're going to get is links to tutorials, which you could perfectly well have found for yourself by simple web searches.

  • Insert data to MySQL when there is new data in the text file

    I have one log file, the log file will update its data (alarm type & datetime) when there is alarm. If I would like to write program to monitor the log file every minute, and insert the data to mysql when there is a new data in log file. Any Idea how to use java to write it ?
    Thanks !

    imagination21 wrote:
    Any Idea how to use java to write it ?Yes. But do you have a specific question? What's the problem?

  • How to fetch the data from pl/sql table dynamically

    Hi All, I have the requirement of comparing two db views data in pl/sql. So, I have bulk collect the view into pl/sql table. But, the issue is, It is expecting to provide the column name for comparison. But, in my case, column name is dynamic. So, i cannot provide the column name directly for comparison.
    For eg: In my view t1_VW, i have 4 columns. stid, c1,c2,c3,c4 and similar structure for t2_vw
    my code
    TYPE v1_type IS TABLE OF t1_vw%ROWTYPE;
    l_data v1_type;
    TYPE v1_type1 IS TABLE OF t2_vw%ROWTYPE;
    l_data1 v1_type1;
    test varchar2(1000);
    test1 varchar2(1000);
    temp1 number;
    begin
    SELECT * Bulk collect into l_data
    FROM T1_VW;
    SELECT * Bulk collect into l_data1
    FROM T2_VW;
    select l_data(1).stid into temp1 from dual; -- It is working fine and gives me the value properly
    -- But, in my case, we are reading the column names from array, i am constructing the query dynamically and execute it.
    test :='select l_data(1).stid into temp1 from dual';
    execute immediate test into temp1;
    -- I am getting error as follows:
    Error report:
    ORA-00904: "L_DATA": invalid identifier
    ORA-06512: at "SYSTEM.BULKCOMPARISON", line 93
    ORA-06512: at line 2
    00904. 00000 - "%s: invalid identifier"
    *Cause:   
    *Action
    end;
    - Please help me to get rid of this issue. Is it possible to construct the query dynamically and fetch the data?. If not, is there any other better approach to compare the data between two views?.

    Output should display what are all columns changed and its old value and new value.
    For eg., output should be
    COLUMNNAME OLD_VALUE NEW_VALUE STID
    C1 20 10 1
    C2 50 40 2
    C3 60 70 2
    C2 80 90 3Why no do this only via a simple sql ?
    create table a (STID number, C1 number,  C2 number, C3 number);
    insert into a values (1, 20, 30, 40)
    insert into a values (2, 40, 50, 60);
    insert into a values (3, 90, 80, 100);
    create table b as select *
    from a where 1 = 0;
    insert into b values (1, 10, 30, 40)
    insert into b values (2, 40, 40, 70);
    insert into b values (3, 90, 90, 100);
    commit;And now you can issue such a kind of select
    SELECT stid , c1, c2, c3                      
       FROM
      ( SELECT a.*,
             1 src1,
             to_number(null) src2        
       FROM  a   
       UNION ALL
       SELECT b.*,
             to_number(null) src1,
             2  src2        
        FROM b
       GROUP BY stid , c1, c2, c3
       HAVING count(src1) <> count(src2)
       order by stid;I would then create a new table a_b_difference having the same structure as a or b and insert into it like this
    create table a_b_diff as select * from a where 1 = 0;
    insert into a_b_diff
    SELECT stid , c1, c2, c3                      
       FROM
      ( SELECT a.*,
             1 src1,
             to_number(null) src2        
       FROM  a   
       UNION ALL
       SELECT b.*,
             to_number(null) src1,
             2  src2        
        FROM b
       GROUP BY stid , c1, c2, c3
       HAVING count(src1) <> count(src2)
       order by stid
       ;Then each time there is a difference between a column in a and its equivalente one in b (per unique stid ) a record will be inserted in this table.
    You can do more by adding the name of the table in front of each record in this table to see exactly where the data comes from
    Best Regards
    Mohamed Houri

Maybe you are looking for

  • Data Connection to PowerPivot Workbook on Sharepoint Online

    Hi, we have an on-premise Sharepoint environment where we publish PowerPivot workbooks that serve as the source database for pivottables in other Excel workbooks.  Is there a way to do something similar with Sharepoint Online where we would upload a

  • Thunderbolt/Firewire adapter backwards compatible?

    So I just bought a new 4TB G-Raid w/ Thunderbolt. Additionally, I bought a Thunderbolt to FireWire adapter, so I can connect my Firewire 800 equipped mac to the hard drive. IT DOESN'T WORK . I've read that they only work with a Thunderbolt equipped m

  • SCSM R2 Duplicate Email Notifications

    Hello anyone! I recently installed SCSM R2 on Windows Server 2012 R2 and created my Service Manager environment. I incorporated an Active Directory connector so I could notify affected users and assigned users of incident creation, assignment and res

  • Cannot charge ipod touch (3G) with wall charger, only using MAC.

    I've had my Ipod Touch for over a year. Suddenly yesterday the device will not charge with either a wall (a/c) charger or a car charger. I have two wall chargers and neither one works. It will only charge when plugged into a usb port on my MAC comput

  • Spatial Query that uses Result of another Spatial Query

    Hi all, I am using the SDO_DIFFERENCE Operator to return the difference between a query window and an intersection geometry. This is fine and i get an object back that is cast to a STRUCT using the SDO API. I want then to use this (returned)object in