Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners problem in setting the values from database
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


kezia simon
problem in setting the values from database
1 Answer(s)      a year and 7 months ago
Posted in : Java Beginners


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!!!!


Advertisement
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
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
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
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
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 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="<
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 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
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 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 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
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
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
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
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 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 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 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
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
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
Advertisements
 

 

 

DMCA.com