code for insert button

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.









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
JSP Radio Button MySQL insert - JSP-Servlet
with the code to store radio button data and checkbox data to MySQL table. For example in the backend table there is only one column for Gender, how do I insert male...JSP Radio Button MySQL insert  Hi, I have an HTML form which has
insert code using spring - Spring
insert code using spring  Hi, Can any one send code for inserting the data in database using spring and hibernate .. Many thanks, Raghavendra  Hi Friend, Please visit the following link: http
help in insert code - JSP-Servlet
help in insert code  I have some doubt in following code. I want to insert value using prepared statement.we r accessing connection from other...;insert regiform values('"+firstname+"','"+address+"','"
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 to disable back button of browser
code to disable back button of browser  code to disable back button of browser
code to disable back button of browser
code to disable back button of browser  code to disable back button of browser
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
Code to insert date in to database - Development process
Code to insert date in to database  Hi , in my following code i want... getting error . plz send me code Error 500--Internal Server Error...:170)   Hi Friend, Try the following code: Thanks
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
insert
insert  insert data in database from servlet through JDBC   Ho Friend, Please visit the following:ADS_TO_REPLACE_1 Insert data into database Thanks
Insert a row in 'Mysql' table using JSP Code
Insert a row in 'Mysql' table using JSP Code In this section, we will discuss about how to insert data in Mysql database using JSP code. Query... between your Tomcat server & Mysql database Table. Code to insert row in Mysql
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
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
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
php code: how to insert manual date and also retrieve records by selecting date field. - Date Calendar
php code: how to insert manual date and also retrieve records by selecting date field.  In PHP, how to insert user input date on mysql db. and also... to get the records by selecting date field in mysql. Please give me a correct code
Button
Button  How to use image for button in JSF
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
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
Insert Operation - WebSevices
Insert Operation  Send the code for Insert Contact in pop up window... If i click one button, pop up window will open, inside the pop up window i insert my contact details(Name,email and etc).So,send the code and solution
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
insert query in jsp
insert query in jsp  give me insert code in jsp at run time
DB Insert
DB Insert  How to insert XML data into a database column? Column data type is CLOB
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     
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
The INSERT INTO Statement, SQL Tutorial
To insert a new row in a database table we have to write the given below code...The INSERT INTO Statement       The INSERT INTO statement is used to insert or add a record
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... Insert data in mysql database through jsp using prepared statement... running this java code you need to paste a .jar file named mysql connector.jar
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
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
INSERT CAPTCHA - WebSevices
INSERT CAPTCHA  HI ALL WISH U A GREAT DAY . I HAVE TO INSERT IMAGE CAPTCHA IN MY FORM . WHEN THE USER HAS... BUTTON . ANY JSCRIPT IDEAS ? THANKS IN ADVANCE ESWARAMOORTHY.S  
insert data
insert data  i've got a problem to insert my data to database.i can... herewith my source code..a)index.jsp<%@ page import="java.util.Date...("insert into images values(?,?,?,?,?)"); st.setString(2
The INSERT INTO Statement
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
Insert Image into Mysql Database through Simple Java Code
Insert Image into Mysql Database through Simple Java Code... simple java code that how save image into mysql database. Before running this java code you need to create data base and table to save image in same database
Mysql Insert
Mysql Insert       Mysql Insert is used to insert the records or rows to the table. Understand with ExampleADS_TO_REPLACE_1 The Tutorial illustrate an example from 'Mysql Insert
Code
Code  code for connecting c lang to database
code
code    how to write this in java
code
code  code for android sample program
code for this is
code for this is  a b c d c b a a b c c b a a b b a a a code
insert data into database
insert data into database  type Exception report message...)Click Add button and select the driver Microsoft Access Driver(*.mdb). 3)After selecting the driver, click finish button. 4)Then give Data Source Name
code
code  please provide code for custom tags.by using currdate tag we need to get current date?please give me code

Ads