Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC JDBC code to save a data in the database

Have Programming Question? Ask it here!
 
 
 


Pranit Sonawane
JDBC code to save a data in the database
1 Answer(s)      2 years and 3 months ago
Posted in : JDBC


I need a code to save a data in the database can anyone help?


Advertisement
View Answers

May 9, 2012 at 12:37 PM


The given code set up the connection between java and mysql using JDBC and saves the data into the database.

import java.sql.*;

public class InsertValues{
 public static void main(String[] args) {
 System.out.println("Inserting values in Mysql database table!");
  Connection con = null;
  String url = "jdbc:mysql://localhost:3306/";
  String db = "jdbctutorial";
  String driver = "com.mysql.jdbc.Driver";
  try{
  Class.forName(driver);
  con = DriverManager.getConnection(url+db,"root","root");
  try{
  Statement st = con.createStatement();
  int val = st.executeUpdate("INSERT employee VALUES("+1+","+"'Roseindia'"+")");
  System.out.println("1 row affected");
  }
  catch (SQLException s){
  System.out.println("SQL statement is not executed!");
  }
  }
  catch (Exception e){
  e.printStackTrace();
  }
  }
}

For more information, visit the following link:

JDBC Tutorials



Related Tutorials/Questions & Answers:
How to save database data into excelsheet using hibernate
How to save database data into excelsheet using hibernate  How to save database data into excelsheet using hibernate
save switch data into database - Java Beginners
save switch data into database  switch(menu) { case 1://add...;  Hi Friend, Try the following code: import java.sql.*; import..."); Connection con = DriverManager.getConnection("jdbc:mysql://localhost
Advertisements
code save word file in 10g database - SQL
code save word file in 10g database  I am not having any idea to save..., Try the following code: import java.io.*; import java.sql.*; public... = DriverManager.getConnection ("jdbc:oracle:thin:@localhost:3306:test","root", "root
code to establish jdbc database connectivity in jsp
code to establish jdbc database connectivity in jsp  Dear sir, i'm in need of code and procedure to establish jdbc connectivity in jsp
code to establish jdbc database connectivity in jsp
code to establish jdbc database connectivity in jsp  Dear sir, i'm in need of code and procedure to establish jdbc connectivity in jsp
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... Insert Image into Mysql Database through Simple Java Code
How to read data from txt file and save to database MySql - Java Beginners
How to read data from txt file and save to database MySql  Please help me again ,my problem right know is how to read data from txt file then data save to database from JButton.Please give me a tutorial and source code
Application reading data from JDBC database
" should read data from from a JDBC database named PrimeGame with TABLE PRIMEGAMETABLE...Application reading data from JDBC database  I would like to develop an online registration system that captures details of potential candidates
export data from database to excel sheet - JDBC
export data from database to excel sheet  I am facing a problem about exporting required data from database table to ms-excel sheet.i mean whenever I... reply for me Thank you!  Hi Friend, Try the following code
How to Validate JRadioButton and How to Save data from JRadioButton to MS Access Database - Java Beginners
How to Validate JRadioButton and How to Save data from JRadioButton to MS... JRadioButton I want Store Information from JRadioButton to MS Access Database, and I want Select any One JRadioButton At a Time out of Two. plz Give Me Code Sir
save data in excel
save data in excel  hello sir, i'm new to this field i want to know can i save data in excel by html forms input,means if any one fill up form online then it is save offline in excel how can i do it can you give me solution sir
save data in excel
save data in excel  hello sir, i'm new to this field i want to know can i save data in excel by html forms input,means if any one fill up form online then it is save offline in excel how can i do it can you give me solution sir
HTML code to servlet to database using jdbc
HTML code to servlet to database using jdbc  pls send me the code related to the title   Hi Friend, Try the following code: 1)form.html: <html> <form method="post" action="http://localhost:8080/examples/Data
save data DAO
save data DAO  how to save data in db   package com.tcs.ignite.dao; import com.tcs.ignite.bean.User; import com.tcs.ignite.connection.Connectiondetails; import java.sql.ResultSet; import java.sql.SQLException; import
code for selected checkbox columns data from database
code for selected checkbox columns data from database  in my page iam... one or more checkboxes i have to get data of that selected columns only. what is the jsp code for this thanks in advance kalyani
How to save data - Swing AWT
How to save data  Hi, I have a problem about how to save data ,but first before data save to dababase, data must view in jLisit or Jtable... save data from jList and Jtable(in jList or jTable data will be many).Thank's
place data in text fields from database using jdbc
place data in text fields from database using jdbc  i want get the data from database and place the records in the respective textfields using jdbc and swing like eno,ename,loc from emp table
To save table format data in pdf/excel in jsp
To save table format data in pdf/excel in jsp  Hello, I am doing web application project in jsp. In webform ,I am displaying database data in html table. So my question is ,I want so save this html format data in pdf/excel format
Save JRadioButton Text in to database - Java Beginners
Save JRadioButton Text in to database   Hello Sir I have Two JaradioButtons 1)Semwise Course 2)Yearwise Course I want To Save Text from...(); JOptionPane.showMessageDialog(null,"Data is successfully inserted into database."); } catch
Save a pdf with spring as below code
Save a pdf with spring as below code   c:/report.pdf All work in the same way, but never save the report to disk. How to solve this problem? please reply me
JDBC - Java Database Connectivity Tutorial
into mysql database. Before running this java code you need to create data base... JDBC - Java Database Connectivity Tutorials  ... stored into the database. Here is the complete tutorial on JDBC technology
How can we save a data list in jsf?
How can we save a data list in jsf?  I have a code in jsf that fires a query in Data Base each time it is called, i have added a validation check... it is called again. I tried using save State but it did not help as other functions got
jsp code for display of data from database and snap shot of the output
jsp code for display of data from database and snap shot of the output  i am using JSP.i want to insert data into database and also want to display the things i have entered in the same page inside the corresponding fields
how can i create a mysql database to connect to this code - JDBC
how can i create a mysql database to connect to this code  i need help creating a mysql database for this code. code is import java.awt...."); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register
how can i create a mysql database to connect to this code - JDBC
how can i create a mysql database to connect to this code  i need help creating a mysql database for this code. code is import java.awt...."); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register
The code for retrieving data from database into Drop Down List.
The code for retrieving data from database into Drop Down List.  <% DataSource data = new MysqlDataSource(); Connection con...;% } %> // my code for displaying quantity is below
Save the input data until user get changed
Save the input data until user get changed  I would like to know how to store the give input data and perform the calculations even after re-opening... and save this amount until he changes it again. Thank You
Save the input data until user get changed
Save the input data until user get changed  I would like to know how to store the give input data and perform the calculations even after re-opening... and save this amount until he changes it again. Thank You
Save the input data until user get changed
Save the input data until user get changed  I would like to know how to store the give input data and perform the calculations even after re-opening... and save this amount until he changes it again. Thank You
Insert image from user using and save in database
Insert image from user using and save in database  when i am trying to upload a image from user and trying to save into oracle9i database.... Apache Tomcat/6.0.29  We have used MySQl database. 1)page.jsp: <
how to save uploaded image in database using javascript
how to save uploaded image in database using javascript  Please can you tell me how to store uploaded image in database using java I'll use the upload code as extArray = new Array(".gif", ".jpg", ".png"); function LimitAttach
how to make a radiobutton selected when retrieving data from database using struts framework and spring jdbc
how to make a radiobutton selected when retrieving data from database using struts framework and spring jdbc  how to make a radio button selected when retrieving data from database using struts framework and spring jdbc
jdbc code - JDBC
jdbc code  are jdbc code for diferent programs are same or different?please provide me simple jdbc code with example?  Hi Friend, Please visit the following link: http://www.roseindia.net/jdbc/ Here you
SQL database parameters should save at where?
SQL database parameters should save at where?  Hi, Currently... the script will be running for very long time, I like to move the SQL database..., if there is a database changed (hostname, username or password) It should
SQLGrammarException while trying to save data in db
SQLGrammarException while trying to save data in db  //hibernate cfg file// <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate... name="connection.url"> jdbc:mysql://localhost:3306/student
jdbc code - JDBC
jdbc code  Dear Sir, i have created one jsp with two fields 1.username 2.password and i have connected to database when the user had entered the fields there are stored in database upto
i want to save image on server folder. and i want to save URL of this folder and name of image in database
i want to save image on server folder. and i want to save URL of this folder and name of image in database  hi i want to save image on server folder. and i want to save URL of this folder and name of image in database.on click
how to import excel sheet into mysql database and save it as a table in database
how to import excel sheet into mysql database and save it as a table in database  sir, i want to import an excel sheet into a MySQL database and after importing it i want to store the excel sheet as a table in database
JDBC + AQUA DATA STUDIO
JDBC + AQUA DATA STUDIO  Hello, i have aqua data studio database. I want to do crud operation in jdbc connection using this databse. can you help me out to do this ?? Thanks
how to show data in database ?
how to show data in database ?  how to show the data in the database to the user in the textbox so that user can modify it and save it again
database - JDBC
database  hai friend, yes i want to use java database connection in eclipse IDE. Thanks in advance
Save profile and image to mysql database, and view the image in another jsp page
Save profile and image to mysql database, and view the image in another jsp page  Pls. need help in saving the profile info with the image in mysql database.. some basic code pls in jsp... thanks in advance
jdbc code
jdbc code   import java.sql.*; import java.io.*; import java.util.*; public class CallBill { public static void main(String args[])throws... oracle.jdbc.driver.OracleDriver()); Connection con=DriverManager.getConnection("jdbc:oracle:thin
Multi value data - JDBC
Multi value data  Hello, please help,how do i use Multi-value data with mysql database. thank you  Hi friend, Plz explain your problem in details what you want and visit to : http://www.roseindia.net/jdbc/jdbc
database entry using jdbc
database entry using jdbc  Give me a program to enter records in table using jdbc in java.   Hi Friend, Please visit the following link: Insert data into database Thanks
How to save form data to a csv file using jquery or ajax
How to save form data to a csv file using jquery or ajax  Please let...) {// code for IE7+, Firefox, Chrome, Opera, Safari data=new XMLHttpRequest(); } else {// code for IE6, IE5 data=new ActiveXObject
insert and delete data in database
insert and delete data in database  insert and delete data in database from servlets through JDBC   Hi Friend, Please visit the following links: Insert Data Delete Data Thanks
database connectivity - JDBC
database connectivity  can u ppl pls provide me with database... DSN,then follow these steps: 1. Open Data Sources (Start->Control Panel->Administrative Tool->Data Sources(ODBC) 2. Open User DSN tab 3. Add
image retrive into DataBase - JDBC
the image into DataBase. Thanks & Regards, VijayaBabu.M  Hi, Retrieving image from database is easy task. JDBC provides all the necessary API and function to retrieve the image from database. You retrieve image from database
Java save file to database
Java save file to database In this section, you will learn how to insert file to database. Description of code: Firstly, we need to establish a connection...(); } } Through the above code, you can insert any file into the database
Advertisements
 

 

 

DMCA.com