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 databaseproblem 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 databaseget
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 DatabaseProblem 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-Servletgetting
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 viewsRetrieve
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 fieldfetch
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 fieldfetch
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
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 jsphow 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 edit values in textboxes from database using jspHow 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
problem in setting path - Antproblem 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
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 problemdatabase 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 problemdatabase 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 JComboBoxDatabase 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 Create Bar Chart with database valuesCreate 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
Problem in Jsp and database - Development processProblem 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
edit values of database using jspedit
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 jspedit
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 valuesArraylist
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 Beginnerssetting 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
Oracle 9i database problemOracle 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