problem in setting the values from database

problem in setting the values from database

hello friends, can anyone help me?? I am facing this problem for past one week. I could't set the values from database. here is the code:

private JTextField getJTextField1() {
        if(text == null) {
            text = new JTextField();
        }
        return text;
    }


    private AbstractAction getSearch() {
        if(search == null) {
            search = new AbstractAction("SEARCH", null) {
                /**
                 * 
                 */
                private static final long serialVersionUID = 1L;

                public void actionPerformed(ActionEvent evt) {          
                    try{
                         ResultSet rs;
                        String st1=text.getText();

                           Class.forName("com.mysql.jdbc.Driver");

                      Connection  con=DriverManager.getConnection("jdbc:mysql://192.168.36.1:3306/atmconsol","project","password");
                      PreparedStatement  pst=con.prepareStatement("select * from form1 where TerminalID=?");
                  System.out.println(st1);
                      pst.setString(1, st1);
                         JOptionPane.showMessageDialog(null,"Prepared Stmt after setting the values " + pst.toString());


                      rs = pst.executeQuery(); 

                      gui.display1 ts= new gui.display1();
                         ts.dis(st1);
                         System.out.println(ts);


                          }
                            catch (Exception e)
                            {
                            JOptionPane.showMessageDialog(null,"TRY AGAIN!!!Cannot find such ID!");
                            text .setText("");
                             text.requestFocus(true);
                            System.out.println("error while validating"+e);
                            e.printStackTrace();
                            System.out.println(e);  
                }

                }
            };
        }
        return search;
    }

} 

//**display1.java**//

void dis(String st1)
        {
        try
        {     
                 String st=td.getText();
                 String st2=make.getText();
                 String st3=proto.getText();
                 String emv=text.getText(); 
                 String st5=bnqry.getText();
                 String st6=fc.getText();
                 String st7=ft.getText();
                 String st8=pc.getText();
                 String st9=ms.getText();
                 String st10=cb.getText();
                 String st11=wd.getText();

                      Class.forName("com.mysql.jdbc.Driver").newInstance();
                         Connection connt = DriverManager.getConnection("jdbc:mysql://192.168.36.1:3306/atmconsol","project","password");
                         PreparedStatement pstmt = connt.prepareStatement("select TerminalId,make,protocol,EMVsupport,BalanceEnquiry,Fastcash,fundtransfer,chequebook,pinchange,ministatement,withdrawal from form1 where TerminalId=?;");

                        pstmt.setString(1, st1);
                         ResultSet rs = pstmt.executeQuery(); 
                         while(rs.next())
                         {
                             System.out.println("******* : "+rs.getString("TerminalId"));
                        td.setText(rs.getString(st));
                        make.setText(rs.getString(st2)); 
                        proto.setText(rs.getString(st3));                    
                        text.setText(rs.getString(emv)); 
                        bnqry.setText(rs.getString(st5)); 
                        fc.setText(rs.getString(st6)); 
                        ft.setText(rs.getString(st7)); 
                        pc.setText(rs.getString(st8)); 
                        ms.setText(rs.getString(st9)); 
                        cb.setText(rs.getString(st10)); 
                        wd.setText(rs.getString(st11)); 

                         }

                         JOptionPane.showMessageDialog(null,"Prepared Stmt after setting the values " + pstmt.toString());

        }catch(Exception ex)
{
                             JOptionPane.showMessageDialog(null,"Error!");
                             System.out.println("error while validating"+ex);
                             ex.printStackTrace();
}

}

can anyone help me out of this issue plzzz!!!! Thanks in advance!!!!

View Answers

May 18, 2013 at 5:16 PM

hi friend,

You are trying to set the value of Terminalid in the SQL query to String put the ? between single quote ('). Probably error is generating from this statement.

Thanks.









Related Tutorials/Questions & Answers:
problem in setting the values from database
problem in setting the values from database  hello friends, can... the values from database. here is the code: private JTextField getJTextField1... Stmt after setting the values " + pst.toString()); rs
get values from Excel to database
get values from Excel to database   hi i want to insert values from Excel file into database.Whatever field and contents are there in excel file that should go to database which exists. am using SQL Server management studio
Advertisements
Problem in accessing data from Database
Problem in accessing data from Database  hi..... i'm making a project on servlet and jsp with ms access 2007 at the backend. One field in my database... someone plz help me out with this problem
insert values from excel file into database
the following link: Insert values from excel file to database...insert values from excel file into database   hi i want to insert values from Excel file into database.Whatever field and contents are there in excel
getting values from database - JSP-Servlet
getting values from database  I tried the following code abc.html aaa.jsp I am not getting exceptions now... JSP code separately.If it will not display database values then try your code
Retrieve values from database using views
Retrieve values from database using views  hi......... I have a huge database so i have created views in database where i am selecting only... from that created views and display on form . I am trying to do so but its
fetch values from database into text field
fetch values from database into text field  please provide the example for fetching values from database into text field of table as if i am trying following String query = "select * from LTCINFO.PERSONS"; st1
fetch values from database into text field
fetch values from database into text field  please provide the example for fetching values from database into text field of table wth edit... * from LTCINFO.PERSONS"; st1 = con.createStatement(); rs = st1.executeQuery(query
Facing Problem to insert Multiple Array values in database - JSP-Servlet
Facing Problem to insert Multiple Array values in database  Hai... facing the problem while inserting the data in database. iam using the MsAccess Database My Database structure is Like iam using tow tabel ,CustomerDetails
How to store extracted values from xml in a database? - XML
How to store extracted values from xml in a database?  I want to store extracted xml values in a database... How can i store extacted xml values in a database... give me a example
How to store extracted values from xml in a database? - XML
How to store extracted values from xml in a database?  I want to store extracted xml values in a database... How can i store extacted xml values in a database... give me a example
how to get the values to dropdownlist from oracle database
how to get the values to dropdownlist from oracle database   </script> </head> <body> <select name... * from countryname"); while(rs.next()){ %> <option value="<
problem in selecting second arraylist from mysql database
problem in selecting second arraylist from mysql database  Hi... in mysql database. In the below program , i have hard-coded that second list, but i want second list to be dynamic from database. Please, help me out. Thank
Want solution to get values for xml namespace tags from database in java
Want solution to get values for xml namespace tags from database in java ...:loc=" "/> now i need to get values from sql database for values in the blank field(" "). how do i get these values.. already connected database and created
how to retreive values from MS Access Database based on the values entered in textbox values in jsp file
how to retreive values from MS Access Database based on the values entered... in MS Access Database. the table structure is Sno JobName ProgramName Problem... in the database fields JobName, ProgramName and Problem whether any single match is found
how to read values from excel sheet and compare with database using jsp
how to read values from excel sheet and compare with database using jsp  hi sir i am arun how to read values from excel sheet and compare...,serialno) values of excelsheet we have to compare with database value if these 3
How to update,Delete database values from jtable cells ..
How to update,Delete database values from jtable cells ..  Hello Sir... from database to jtable .Now as per my requirement i need to update and delete the database records from the table cells by entering new values there only
How to update,Delete database values from jtable cells ..
How to update,Delete database values from jtable cells ..  Hello Sir, I am working on a project in which i have to fetch the values from database... records from the table cells by entering new values there only ... Sir,plz send me
how to display values from database into table using jsp
how to display values from database into table using jsp  I want to display values from database into table based on condition in query, how... the values from database based on the bookname or authorname entered must be display
How to update,Delete database values from jtable cells ..
How to update,Delete database values from jtable cells ..  hello Sir... from database into jtable of a jpanel.. Now Sir, According to my need i have to update the cell values from there only means that whatever values i ma entering
How to extract values from SOAP Response message and insert in database
How to extract values from SOAP Response message and insert in database ... values from SOAP Response XML (i.e. Empname,EmpID,Phnumber) but I don't have any idea of XML.Also I need to update these parsed values into the database. Can you
graph generation using jfreechart and retrieving values from the database
graph generation using jfreechart and retrieving values from the database  I have made a database containing 4 subject marks and name and roll no. of students.The dsn name is chartdsn. I want to retrieve the data from the access
Autopopulate values into textbox from database on pressing tab or on clicking
Autopopulate values into textbox from database on pressing tab or on clicking  Hi, In my project we have to enter a productid which is first need to be searched into database. if it already exists then it will autopopulate its
How to fetch entries/values from database to a jsp page one by one?
How to fetch entries/values from database to a jsp page one by one?  I have a table in Microsoft SQL server Management Studio with two columns title... to display different database entries of the each column in different blocks. Now
How to edit values in textboxes from database using jsp
How to edit values in textboxes from database using jsp  Hi RoseIndia, I need help to solve my technical problem, i want to edit values in textboxes from database table using jsp, here is my code Please can anyone help me
how to import values from database to the drop down box
how to import values from database to the drop down box   hi iam final year student in my project i will insert all employee details in search employee page i kept a drop down box for employee Ids i want all employee IDs
How to insert and update all column values of database from jtable.
How to insert and update all column values of database from jtable.  Hello Sir, I have developed a swing application in which database table... ,update,delete database values from jtable only so i added three buttons add
problem in setting path - Ant
problem in setting path  hi friends i am getting a problem in setting but i followed the procedure same as like in http://www.roseindia.net... Do some changes setting the path : 1)ANT_HOME=D:\installations\apache
How to insert and update all column values of database from jtable.
How to insert and update all column values of database from jtable.  ... ,update,delete database values from jtable only so i added three buttons add,update... rowToDelete){ // Mark row for a SQL DELETE from the Database
How to insert and update all column values of database from jtable.
How to insert and update all column values of database from jtable.  ... ,update,delete database values from jtable only so i added three buttons add,update... rowToDelete){ // Mark row for a SQL DELETE from the Database
problem from registering a data in database with servlet - JSP-Servlet
problem from registering a data in database with servlet  Hi Rose, i created a servlet to validates ten user details in the database, if present...); System.out.println("Connected to the database"); String query1="Select * from user
Need solution to get values for XML namespace tags from SQL database in Java
Need solution to get values for XML namespace tags from SQL database... comp:loc=" "/> now i need to get values from sql database for values in the blank field(" "). how do i get these values.. already connected database
problem in database
problem in database   thanks for web site. I want change this code to insert data into PostgreSql database using jsp,servlets. but i getting... into sample VALUES(?,?)"); pst.setString(1,username); pst.setString(2,pass
database problem
database problem  I did connect my jsp page to database and it showed the result on another jsp page but i want to show the data of that field on which i click to mouse from the jsp page where all the data field has been showed
database problem
database problem  I did connect my jsp page to database and it showed the result on another jsp page but i want to show the data of that field on which i click to mouse from the jsp page where all the data field has been showed
Database values in JComboBox
Database values in JComboBox In this section, you will learn how to display values in JComboBox from database. For this, we have allowed the user to enter any character as a key in the textbox .Based on this key value, the results from
how to store multiple values from drop down in database where i am using java struts 1.3
how to store multiple values from drop down in database where i am using java struts 1.3  hii, i am coding a form where i need a keyskills attribute... is displaying.. i need code in java so that it takes multiple values
Create Bar Chart with database values
Create Bar Chart with database values In this section, you will learn how to create a bar chart by retrieving the values from the database. For this purpose... from MySQL database and then using the jfree chart library to create chart
i am getting the problem when i am downloading the pdf file from oracle 10g database - Struts
i am getting the problem when i am downloading the pdf file from oracle 10g... into datbase and download the pdf file from database. but when i created the pdf file from the struts application(itext.jar),it is uploading into database
Problem in Jsp and database - Development process
Problem in Jsp and database  Hi, How can I reterive values from database and display them in teextboxes so that when the user select the UPDATE option, he can modify the values entered by him and the changes are made
How to display all the Select values from the MySQL database table in where condition= In JSP?
How to display all the Select values from the MySQL database table in where... to display all the select values from MySQL DB** only first value is displayed in the jsp file. @select * from table dept where dept_no=10;" jsp code i have used
edit values of database using jsp
edit values of database using jsp  hi i want a code to edit the row from tye database and display in a page which containd radio buttons and drop down boxes using jsp code
edit values of database using jsp
edit values of database using jsp  hi i want a code to edit the row from tye database and display in a page which containd radio buttons and drop down boxes using jsp code
Arraylist from row values
Arraylist from row values  Hello, can anyone please help on how to make an arraylist from the row values of a particular column from a database...("select * from employee"); ArrayList<String> list=new ArrayList<
setting path problem for org.jfree files - Java Beginners
setting path problem for org.jfree files  Hi deepak, As u said, i... org.jfree and so on........after setting the path, i have restarted my system also but then also iam facing the same problem.......... please if u tell me proper
show the database values graphical represantation
show the database values graphical represantation   show the database values graphical represantation and auto refresh for every 30 secand displaying in webpage
inserting dropdown values into database table
inserting dropdown values into database table   hi i want to insert dropdown values into a database table by using jsp
Oracle 9i database problem
Oracle 9i database problem  Hi Somebody has given the solution but i.............,send reply immediately. I have a problem in Oracle9i .I have installed... and columns data ,then i gave command select * from ....; .Then i got the table
Database problem - WebSevices
simple database connectivity code. if you have any problem then send me detail...Database problem  Hello, How i connect my database file...(); String sql = "select * from person"; rs
Struts2...problem in JSP..unable to get the values for menuTitle!!!
Struts2...problem in JSP..unable to get the values for menuTitle!!!  **Hello everyone... i'm trying to make a dynamic menu from database in struts2... Jsp is displaying the menuId from database but not the menuTitle...where as its

Ads