Home Answers Viewqa Java-Beginners code for insert button

 
 


Anshuman Ptaew
code for insert button
2 Answer(s)      a year ago
Posted in : Java Beginners

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 Pages:
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 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
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
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
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
insert code jsp to access
insert code jsp to access   insert code jsp to access
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
facebook like button code
facebook like button code  How to create a facebook like button? can anyone share the code..?? Thanks in advance
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
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
Submit button to MySQL database?
Submit button to MySQL database?  Need help linking html code..." content="text/html; charset=ISO-8859-1"> <title>Insert title here<...="Province" /><br /> Dealer Code: <input type="text" name="Dealer_Code
Submit button to MySQL database?
Submit button to MySQL database?  Need help linking html code..." content="text/html; charset=ISO-8859-1"> <title>Insert title here<...="Province" /><br /> Dealer Code: <input type="text" name="Dealer_Code
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
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+"','"
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
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
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
HTML Button Size
HTML Button Size       Button in HTML is used to submit HTML page. Understand with Example The Tutorial illustrate an example from HTML Button size. In this Tutorial we
coding of button
coding of button  What is code of fetching the value of button in a textbox using javascript
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
using insert and delete in a single page in jsp
if the insert button is clicked.. So what is wrong with the code...using insert and delete in a single page in jsp  I am using the following code in jsp to declare two javascript functions to insert and delete
Insert Image in DB through Servlet - JSP-Servlet
Insert Image in DB through Servlet  Dear Sir, You write me: copy..._WinZip_File.zip Check there a button called "FreeUser" Click on that button... there it will ask for save. save it extract it then use the code inside
HTML5 button tutorial, Example of form and formaction attribute of button.
Button disabled in HTML5. Introduction: In this section, you will see the use of form and formaction attribute of button tag. If form attribute presents in button. It specifies related form. The action attribute of form tag
submit button
submit button  <p>hi I am trying to insert record in database using hibernate in JSP(Netbeans). When I click insert button it should go...; <input type="submit" value="Insert" name="login" /> <
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
button tag
button tag  how do i change button color to black. meant to say i want black button with white text on it   Hi Friend, Try the following code: <html> <script> function getMes(){ var message
Insert Image in DB through Servlet - JSP-Servlet
Insert Image in DB through Servlet  Dear Sir, My previous Query... pre = conn.prepareStatement("insert into MyPictures values...(e.getMessage()); } } } Whether Any entry will be made in web.xml when Insert Image
insert excel value in to oracle data base
insert excel value in to oracle data base  Hi All I am using this code for saving excel value to oracle database table. code is working properly... org.apache.poi.hssf.usermodel.HSSFCell@19360e2 i am not getting right value... my code
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
button in java
button in java  how can i compare names of two buttons after...) { System.out.println("button clicked"); } } Thanks   Hi Friend, You can use the following code: import java.awt.*; import javax.swing.
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 data into mysql databse using swing
insert data into mysql databse using swing   Blockquote hi, here is my code, i want code for store data into mysql database when click on submit button from access data from this form, please provide code, import java.awt.
insert query in jsp
insert query in jsp  give me insert code in jsp at run time
The INSERT INTO Statement
the given below code: INSERT INTO employee  VALUES ('Amar...The INSERT INTO Statement       The INSERT INTO statement is used to insert or add a record
To Upload and insert the CSV file into Database
To Upload and insert the CSV file into Database... to upload a CSV file through JSP and insert it into the database. For this, we have... to be uploaded and a button to submit the request. The action is performed
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
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
Difference between Normal Insert and BLOB insert
parameter error. Here is a code that insert image into database: import java.sql....Difference between Normal Insert and BLOB insert  I have sql database...), DisplayImage (image). Table has 2 rows for first row i have written insert into Image
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  
Java Multiple Insert Query
Java Multiple Insert Query In this example we will discuss about how to execute multiple insert query in Java. This example explains you about how to execute batch insert in Java. This example explains all the steps for executing
insert into statement in sql using servlets
insert into statement in sql using servlets   ... insert a value from a html form in the table stored in the database. ... we are going to insert the values. Now make one jsp page or  html page
Upload and insert the file contents - Java Server Faces Questions
Upload and insert the file contents  I want to browse and upload 2 files on server and insert the values into table from JSP page. So i have to browse and upload CSV files using the browse and upload button. as soon as i
Insert Operation Error - WebSevices
Insert Operation Error  Hai, How i store my full resume in database[Mysql] using PHP. Any one Know the code..... Help me

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.