473,326 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

problem with the output

hi.. to all..
i executed the following program.. i entered the data in the output screen..but the data is not updated in the database.... Is there any problem with the program.. plz help me........

Expand|Select|Wrap|Line Numbers
  1. import java.applet.*;
  2. import java.awt.*;
  3. import java.sql.*;
  4. import java.awt.event.*;
  5. import sun.jdbc.odbc.*;
  6.  
  7. public class Customerdetails extends Frame implements ActionListener
  8. {
  9.  
  10.      TextField ccod,cname,add,phno,conp,email,fax;
  11.      Label l1,l2,l3,l4,l5,l6,l7;
  12.      Button save,exit;
  13.      Connection con;
  14.      ResultSet rs;
  15.      Statement stmt;
  16.      String s1,s2,s3,s4,s5,s6,s7;
  17.  
  18.  
  19. public Customerdetails() 
  20. {
  21.  
  22.     super("CustomerDetails");
  23.     setSize(700,750);
  24.     setLayout(null);
  25.     setBackground(new java.awt.Color(245, 117, 105));
  26.     l1=new Label("Customercode");
  27.     l2=new Label("CompanyName");
  28.     l3=new Label("Address");
  29.     l4=new Label("PhoneNumber");
  30.     l5=new Label("Contact person");
  31.     l6=new Label("EmailAddress");
  32.     l7=new Label("FaxNumber");
  33.     l1.setBounds(20,100,100,70);
  34.     l2.setBounds(20,160,100,70);
  35.     l3.setBounds(20,220,100,70);
  36.     l4.setBounds(20,280,100,70);
  37.     l5.setBounds(20,340,100,70);
  38.     l6.setBounds(20,400,100,70);
  39.     l7.setBounds(20,460,100,70);
  40.     ccod=new TextField();
  41.     cname=new TextField();
  42.     add=new TextField();
  43.     phno=new TextField();
  44.     conp=new TextField();
  45.     email=new TextField();
  46.     fax=new TextField();
  47.     ccod.setBounds(200,120,150,40);
  48.     cname.setBounds(200,180,150,40);
  49.     add.setBounds(200,240,150,40);
  50.     phno.setBounds(200,300,150,40);
  51.     conp.setBounds(200,360,150,40);
  52.     email.setBounds(200,420,150,40);
  53.     fax.setBounds(200,480,150,40);
  54.     Button save= new Button("Save");
  55.     Button exit= new Button("Exit");
  56.     save.setBounds(160,580,100,40);
  57.     exit.setBounds(280,580,100,40);
  58.     add(l1);
  59.     add(ccod);
  60.     add(l2);
  61.     add(cname);
  62.     add(l3);
  63.     add(add);
  64.    add(l4);
  65.    add(phno);
  66.    add(l5);
  67.    add(conp);
  68.    add(l6);
  69.    add(email);
  70.    add(l7);
  71.    add(fax);
  72.    add(save);
  73.    add(exit);
  74.   save.addActionListener(this);
  75.   exit.addActionListener(this);
  76.   setVisible(true);
  77.  
  78.  
  79.  
  80. addWindowListener(new WindowAdapter(){
  81.   public void WindowClosing(WindowEvent w) {System.exit(0);}});
  82. }
  83.  public void actionPerformed(ActionEvent ae)
  84. {
  85. Customerdetails cud= new Customerdetails();
  86.  if(ae.getSource()==save)
  87. {
  88.  s1=ccod.getText();
  89.  s2=cname.getText();
  90.  s3=add.getText();
  91.  s4=phno.getText();
  92.  s5=conp.getText();
  93.  s6=email.getText();
  94.  s7=fax.getText();
  95.  
  96. try
  97. {
  98.       String query = "insert into Customerdetails (Customercode,CompanyName,Address,PhoneNumber,Contact person,EmailAddress,FaxNumber)"+ "values('"+s1+"','"+s2+"','"+s3+"','"+s4+"','"+s5+"','"+s6+"','"+s7+"')";
  99.       Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  100.       con=DriverManager.getConnection("jdbc:odbc:prism");
  101.       stmt=con.createStatement();
  102.       rs=stmt.executeQuery(query);
  103.       stmt.close();
  104.  
  105. }
  106. catch(ClassNotFoundException e)
  107. {
  108.   System.out.println(e);
  109. }
  110. catch(SQLException e)
  111. {
  112.   System.out.println(e);
  113. }
  114. }
  115. else if(ae.getSource()==exit)
  116. {
  117. System.exit(0);
  118. }
  119. else
  120. {
  121. System.exit(0);
  122. }
  123. }
  124.  public static void main(String args[]) 
  125. {
  126.    Customerdetails cud= new Customerdetails();
  127. }
  128. }
  129.  
  130.  
Sep 11 '07 #1
3 1328
praveen2gupta
201 100+
Hi
you are using rs=stmt.executeQuery(query); commands. This is for retreving the data. use following
rs=stmt.executeUpdate(query);
your data will be saved in the database.
Sep 11 '07 #2
Hi...
if i change like this ..
rs=stmt.executeUpdate(query);
it shows me an error..
plz see my codes once again.. i'm not updating the data.....i hav get input data from the user..and hav to add that data to the database..

ragards
pradeep
Sep 11 '07 #3
r035198x
13,262 8TB
Hi...
if i change like this ..
rs=stmt.executeUpdate(query);
it shows me an error..
plz see my codes once again.. i'm not updating the data.....i hav get input data from the user..and hav to add that data to the database..

ragards
pradeep
Read the API docs for the method that was suggested to you. It does not return a ResultSet. You don't need a resultset for inserting/updating data.
Sep 11 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: geoffblanduk_nospam | last post by:
Given a set of intervals {i1, i2, i3, ...} a list is produced; the base items (0) are placed one at a time into the stream and after the ix one a interval item (1, 2, 3, etc) of the correct type is...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
0
by: michael | last post by:
Hi. I have a problem using the CollectioEditor. In my custom control I have a public property that returns ItemList. ItemList is inherited from CollectionBase and contains very simple items...
2
by: yqlu | last post by:
I hava developed a client in C# that is connected to a 3-party XML Web Services developed in Java based on the AXIS 1.1. Most methods call are successful except for one method named "findObjects"...
1
by: leslie_tighe | last post by:
Hello, I have webservice created with Axis 1.2.1 and that I am trying to consuming in .NET (VB) using the Microsoft provided tools. While I am able to consume methods on the service that return...
4
by: leslie_tighe | last post by:
Hello, I have a webservice running on a J2EE server created with Axis 1.2.. I have a client that I am building in .net that needs to consume this webserivce and am having a bit of trouble. I have...
0
by: ryan | last post by:
I've been tasked with consuming a Perl web service that was written by a person in a different department of my company. The problem is it's the guy's first attempt at web services and he doesn't...
2
by: DC | last post by:
The Code <%@ import namespace="System" %> <%@ import namespace="System.Web" %> <%@ import namespace="System.Web.UI" %> <%@ import namespace="System.Web.UI.HtmlControls" %> <%@ import...
2
by: Thelonious Monk | last post by:
I have a problem where some data is being eliminated. The problem is that the data contains signed numeric fields (the low-order byte of a negative number uses the first 4 bits as a sign and...
13
by: jamesonang | last post by:
Supposed unsigned int(32 bits) is the largest number that computer can represent with a single variable. Now, i have a big integer ( less than 64 bit, but great than 32 bit) . i represent it by...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.