Home Answers Viewqa JDBC still error

 
 


anjuvijayan
still error
2 Answer(s)      2 years and 4 months ago
Posted in : JDBC

public NewJFrame() {
    initComponents();
    try
    {
        Class.forName("java.sql.Driver");
      con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","admin");
    }

catch(Exception e)
{
    e.printStackTrace();
}

}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

txtname .setText(""); txtfrom.setText(""); txtgen.setText(""); txtto .setText(""); txttname .setText(""); txtadd.setText(""); txtphone.setText(""); txttrno.setText("");

}                                        
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    {
        try
        {
          st=con.createStatement();
            int a=Integer.parseInt(txttrno.getText());
            String b=txttname.getText();
            String c=txtfrom.getText();
            String d=txtto.getText();
            String k=txtname.getText();
            String f=txtgen.getText();
            String g=txtadd.getText();
            int h=Integer.parseInt(txtphone.getText());
           rs=st.executeUpdate("insert into railway values("+a+",'"+b+"','"+c+"','"+d+"','"+e+"','"+f+"','"+g+"',"+h+")");
        }

con.close(); st.close(); rs.close(); }

catch(Exception e)
{
    e.printStackTrace();


}                                        

public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new NewJFrame().setVisible(true);
        }

full red line s coming guys..... can smone help me in removing errors from ds...........

View Answers

January 28, 2011 at 11:27 AM


Hi Friend,

Why are you using private void jButton2ActionPerformed?

If you want to perform any action on button then use the following code:

Suppose, you have created an object (button) of JButton class then use the following:

button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){

//--------here you can use your insert query------
}
});

Thanks


January 28, 2011 at 7:40 PM


actually m making programmes with tools lik button,textfield etc.. and ds line "private void jButton2ActionPerformed" automatically comes in the programme when i double click d second button which i,ve added in ma frame....









Related Pages:
still error
still error   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
still error
still error  st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
still error
still error  public NewJFrame() { initComponents(); try { Class.forName("java.sql.Driver"); con... second button which i,ve added in ma frame.... plzz smone help me to remove error
still error
still error  public NewJFrame() { initComponents(); try { Class.forName("java.sql.Driver"); con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","admin"); } catch(Exception e
Still getting the http 404 error - Java Beginners
is userid? Anyway, whatever I do, I still receive the http 404 error...saying...Still getting the http 404 error  Dear experts, I refer to the last solution given to me. A few clarification:- 1. I must stress
Itried all possible ways still getting thesame error
Itried all possible ways still getting thesame error  java.sql.SQLException: Io exception: Got minus one from a read call at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112
-[UIPopoverController dealloc] reached while popover is still visible.
-[UIPopoverController dealloc] reached while popover is still visible.  Hi, I am getting following error in my application: -[UIPopoverController dealloc] reached while popover is still visible. How to solver this? Thanks
hello .. still doesn't run - Java Beginners
hello .. still doesn't run  Iam still having a prblem in running... Scanner another error is can not resolve symbol method setname(java.lang.String... r inserting values, why?? u have many basic error in the source code, i have
defined actions in struts config still getting a HTTP 404 - Struts
defined actions in struts config still getting a HTTP 404  Hi guys, I am getting an Invalid Path requested error. Heres the code snippet from... exist and so do the Action classes. Still whenever I pass the .do action
runtime error
runtime error  still i am getting runtime error as:the specified dsn contains an architecture mismatch between the driver and application   Hi, This error is related to some OS related problem. "dsn contains
Registration timer expired, but client is still registering!
Registration timer expired, but client is still registering!  Registration timer expired, but client is still registering
Error in using jstl tags
/jstl/core" %> but still i'm getting the error "CANNOT FIND THE TAG LIBRARY...Error in using jstl tags  I'm trying to use jstl tags in jsp.i've included the jstl.jsr file in lib folder of my project and also written the foll
Error using SoapClient() in PHP
parameter and active SSL on my server, still I'm getting an error. Here is the code I'm...Error using SoapClient() in PHP  I'm trying to access WSDL(Web...","Password" => "password")); Here is the error I'm getting: Warning
Displaying error on the Same form
Displaying error on the Same form  I want to display the errors... to display the error messages. It is working properly. But those error messages.... But the problem is still. Could you please provide me the reason or possible
compilation error - Java Beginners
still i'm not able to make object of Dog clss in Person class!! plezz help ... in same package Dog class is being compiled bt. Person is not compiled . error
Eclipse-Apache tomcat error
but the problem still remians unresolved.please help meout with this. Thanks
Servlet signup still not working satisfactorialy - JSP-Servlet
Servlet signup still not working satisfactorialy  Hello sir thanks for your reply I tried following code given by you, What it has a problem as: I..., it still prints the same output: One of the Mandatary field is empty. What
error
error  while iam compiling iam getting expected error
Error-
Error-   Hello, I would like to know about XSD file. I try to print XML file but I am getting error SAXException-- says Content is not allowed in prolog. Please help me
error
error  i have 404 error in my program plz tell me yhe solution about
error
error  i have 404 error in my program plz tell me yhe solution about
Error
Error  I have created ajax with php for state and city. When I change state then city will not come in dropdown list and it give me error as 'Unknown Runtime Error'. This error come only in IE browser, but in other brower
error
error  java.lang.unsupportedclassversionerror:bad major version at offset 6 how to solve this????   Hi, Please check the version of framework used and also the JDK version. This type error also comes when java file
error
error
error
error  When I deploye the example I have this message cannot Deploy HelloWorld Deployment Error for module: HelloWorld: Error occurred during deployment: Exception while deploying the app [HelloWorld
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern = /^\d{3,5
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
error
"+it); } } this is my program i am getting an error saying cannot find symbol class string
error
error  whats the error.............. import java.util.Scanner; public class g { public static void main(String[] args) { Scanner s=new Scanner(System.in); int d,x,y; System.out.println("Enter the first number
Java code error - Java Beginners
()){ ................................................. Even though I have the if (query != null), I still get a nullPointer
Sources of GPS Error
Sources of GPS Error      ... work is still going on to develop more and more accurate systems, it would be a good idea to understand what the external sources of error are. What's a GPS
Java Compilation error - Java Beginners
? } } when i write [owner = check.resulAcc()throws IOException;] get error there,.. [';' expected] the semicolon i already put at the end like above,..but still the same error.. can u help me solve this problm?please
Java Compilation error - Java Beginners
error there,.. [';' expected] the semicolon i already put at the end like above,..but still the same error.. can u help me solve this problm?please
Java Compilation error - JSP-Servlet
-fileupload-1.2.1.jar but still there is a problem and when i compile my file this error still come. pls can some one help to move out of this? thanks C:\pv>javac
java compilation error - Java Beginners
the codes I still received this message. My program compiles with no errors but I just can't run it ProductInventoryVGUI Uncaught error fetching image... thats maybe why I'm getting that error message. Is there a way I can find an image
JDBC:Runtime error - Java Beginners
,msbase.jar,msutil.jar. But still giving error while running from the batch file... to run the program from command prompt it is giving error. The follwing... to run the batch file it is showing following error
Still have the same problem--First Example of Struts2 - Struts
Still have the same problem--First Example of Struts2  Hi I tried the example in the link. But still I am getting the same problem like as I tried my own example. Its not displaying the "Struts Welcome" message and also
JDBC:Runtime error - Java Beginners
JDBC:Runtime error  Dear sir/madam, thanks to respond for my request. I tried as you said but still i facing the same problem no suitable drivers... the connection closed. but still facing the same problem. Please give the steps which i
Null pointer exception error in Jsp - JSP-Servlet
dear friends i used the name attribute but it still have error of runtimeNULL...Null pointer exception error in Jsp  Expert:Majid Hi i write a login page. when i validate the login value then the nullpointer exception error
Catching Exception using c: catch and c:set
which you think that it can invoke a error, and still you are confident... that the particular code can invoke a error then we should write those codes inside the <c
JSTL c:catch with c:if
that it can invoke a error, and still you are confident that you can recover from... a error then we should write those codes inside the <c:catch> core action tag
download file Error in struts2 action class
download file Error in struts2 action class  Hi, i am using bellow... using still i get the same problem **response.resetBuffer();**//even though i am using still i get the same problem

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.