code for insert button

Ads
 

code for insert button

i want code for insert button(in image) . This is to be used for inserting the values in mysql databasesCapture

View Answers

May 9, 2012 at 5:55 PM

The given code uses Swing components to create a image button and allow the user to enter name and address. As the user clicks the image button, the data will get stored into the database.

    import java.sql.*;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    class  InsertData{
        public static void main(String[] args){
            JFrame f=new JFrame();
            f.setLayout(null);
            JLabel lab1=new JLabel("Name : ");
            JLabel lab2=new JLabel("Address: ");

            final JTextField text=new JTextField(20);
            final JTextArea area=new JTextArea(5,20);
            JScrollPane pane=new JScrollPane(area);
            JButton b=new JButton(new ImageIcon("c:/image1.gif"));

            lab1.setBounds(10,10,100,20);
            text.setBounds(120,10,150,20);

            lab2.setBounds(10,40,100,20);
            area.setBounds(120,40,150,60);

            b.setBounds(120,110,100,20);
            b.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e){
                    String st1=text.getText();
                    String st2=area.getText();
                 try{
                 Class.forName("com.mysql.jdbc.Driver").newInstance();
                 Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
                 PreparedStatement pstmt = conn.prepareStatement("insert into data(name,address) values(?,?)");

                 pstmt.setString(1, st1);
                 pstmt.setString(2, st2 );
                 pstmt.executeUpdate();

                 JOptionPane.showMessageDialog(null,"Inserted Successfully!");
                 }
                 catch(Exception ex){}
                }
            });
            f.add(lab1);
            f.add(text);
            f.add(lab2);
            f.add(area);
            f.add(b);
            f.setVisible(true);
            f.setSize(350,200);
        }
    }

December 18, 2012 at 7:25 PM

can u please post the answer using php and javascript.

Ads









Related Tutorials/Questions & Answers:
code for insert button
code for insert button    i want code for insert button(in image...;The given code uses Swing components to create a image button and allow the user to enter name and address. As the user clicks the image button, the data will get
insert code jsp to access
insert code jsp to access   insert code jsp to access
Advertisements
insert Images using if condition on a button in NetBeans
insert Images using if condition on a button in NetBeans  I wantted to insert Images using if condition on a button that is performed to change... of the source code please! HELP ME
facebook like button code
facebook like button code  How to create a facebook like button? can anyone share the code..?? Thanks in advance
insert , edit , and delete button in one jsp page
insert , edit , and delete button in one jsp page  hello I want to ask about the way of creating a jsp page contains insert , edit , and delete buttons and manipulate data in database directly. any help please or hints
BROWSE BUTTON CODE
BROWSE BUTTON CODE  HOW TO STORE THE FILE BROWSE TO THE DATABASE   JSP File Upload 1)page.jsp: <%@ page language="java" %> <... = connection.prepareStatement("insert into file(file_data) values(?)"); fis = new FileInputStream(f
BROWSE BUTTON CODE
BROWSE BUTTON CODE  HOW TO STORE THE FILE BROWSE TO THE DATABASE   JSP File Upload 1)page.jsp: <%@ page language="java" %> <... = connection.prepareStatement("insert into file(file_data) values(?)"); fis = new FileInputStream(f
code for insert the value from jsp to access database
code for insert the value from jsp to access database  code for insert the value from jsp to access database
java code to insert select at run time....????
java code to insert select at run time....????  java database code to retrieve data at runtime and please give codes for insert delete too.... using...;td><%=rs.getString(5)%></td> <td><input type="button
how to insert, retrieve data from,to db(code)....
how to insert, retrieve data from,to db(code)....  Hi..... i ve... db. cn u plz tel me the code in detail.n i thk it shud b written in jdbc.....i ve written sum code,bt gting so many doubts in that....so plzzzz help
how to insert, retrieve data from,to db(code)....
how to insert, retrieve data from,to db(code)....  Hi, i have created... plz tel me the code in detail.n i thk it shud b written in jdbc.....i ve written sum code,bt gting so many doubts in that....so plzzzz help me by giving some
Submit comments in database when user clicks on submit button
Submit comments in database when user clicks on submit button       This is detailed java code to show how to submit comments from a jsp page and insert it to the MySql
in the below code two errors are there one at the button onclick atttibute and the next is at the next button
in the below code two errors are there one at the button onclick atttibute and the next is at the next button  <%@ page import="java.sql.*" %> function editRecord(id){ var f=document.form; f.method="post
please let me get code how to insert a data to mysql using setter and getter method by using java
please let me get code how to insert a data to mysql using setter and getter method by using java  please let me get code how to insert a data... in pure generic way ..all getter and setter in one class , code to insert to db
please let me get code how to insert a data to mysql using setter and getter method by using java
please let me get code how to insert a data to mysql using setter and getter method by using java  please let me get code how to insert a data... in pure generic way ..all getter and setter in one class , code to insert to db
button
button  can i give multiple commands on click of a button? if yes how can i do that?? multiple commands can we retriving dat from database, capturing data, moving to next page.. etc
button
button  can i give multiple commands on click of a button? if yes how can i do that?? multiple commands can be retriving dat from database, capturing data, moving to next page.. etc
executing multiple sql statements on the single button click...
executing multiple sql statements on the single button click...  how can i frame a code on the click of a button to insert data into a table as well as to retrieve records from the same table in another form
executing multiple sql statements on the single button click...
executing multiple sql statements on the single button click...  how can i frame a code on the click of a button to insert data into a table as well as to retrieve records from the same table in another form
jdbc insert
jdbc insert  Hi , i want to insert a declared integer variable into a mysql table through jdbc. how to insert that. help me with query... thanks in advance   Here is a java code that connects to database and create
Press button and Scroll Image to Scrollpanel
Press button and Scroll Image to Scrollpanel  Insert image into the jpanel,inside the jscrollpane.If i press the button and scroll image
coding of button
coding of button  What is code of fetching the value of button in a textbox using javascript
insert query in jsp
insert query in jsp  give me insert code in jsp at run time
JDBC batch insert
JDBC batch insert       JDBC Batch Insert is a set of SQL Statements sent to the database and executed... Insert, An empty array object is linked, whenever a statement object is created
Print Button
Print Button  i want the source code for printing details of jform.. so plz help me for source code of print button
JDBC Insert Preparedstatement
want to describe you a code that helps you in understanding JDBC Insert Prepared Statement. For this we have a class Jdbc Insert Prepared statement, Inside... JDBC Insert Preparedstatement     
DB Insert
DB Insert  How to insert XML data into a database column? Column data type is CLOB
The INSERT INTO Statement, SQL Tutorial
The INSERT INTO Statement       The INSERT INTO statement is used to insert or add a record of data into the table. To insert records into a table, just write the key word
How to insert rows in jTable?
How to insert rows in jTable?  Hi, I need to take input from user using JTable. I want an empty row to appear after clicking a insert button... not figure out how to. I used DefaultTableModel but wasnt able to insert a row
uikeyboard done button/return button
uikeyboard done button/return button  Hi everyone!!! Just worried about ..how to return the UIKeyboard on done or return button click in my iPhone application. Thanks   Hi, Find the given code that will allow you
Insert data in mysql database through jsp using prepared statement
; This is detailed jsp code that how to insert data into database by using prepared statement... will remain same after clicking on submit button. Download source code... Insert data in mysql database through jsp using prepared statement

Ads