Home Answers Viewqa JDBC JDBC save a data in the database

 
 


Pranit Sonawane
JDBC save a data in the database
1 Answer(s)      a year ago
Posted in : JDBC

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

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 Pages:
save switch data into database - Java Beginners
save switch data into database  switch(menu) { case 1://add a student System.out.print("Enter student ID: "); int ID = scan.nextInt..."); Connection con = DriverManager.getConnection("jdbc:mysql://localhost
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 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
code save word file in 10g database - SQL
code save word file in 10g database  I am not having any idea to save... = DriverManager.getConnection ("jdbc:oracle:thin:@localhost:3306:test","root", "root...(file); pstmt = conn.prepareStatement("insert into file( file, file_data
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: <
JDBC
JDBC code to save a data in the database  I need a code to save a data in the database can anyone help?   The given code set up the connection between java and mysql using JDBC and saves the data into the database
JDBC
JDBC save a data in the database  I need a code to save a data in the database can anyone help?   The given code set up the connection between java and mysql using JDBC and saves the data into the database. import
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...("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc
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 between MySql database and java file with the help of various types of APIs
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
JDBC - Java Database Connectivity Tutorial
JDBC - Java Database Connectivity Tutorials  ... stored into the database. Here is the complete tutorial on JDBC technology...; New Features in JDBC 4.0 Java database connectivity (JDBC) is the Java
jdbc
jdbc   how to write program to save data and retrieve data from the form in Java
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
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
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
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
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
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
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... = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "root
jdbc
methods.   Save point is the point to which we can undo the unsaved data... level can be set in JDBC. the method can accept any of the arguments listed below... work done after the savepoint. A save point is created using the method
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
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
jdbc
jdbc  how to update int values of ms-access in jdbc program?   In MS Access database, use Number data type for int values. import... =DriverManager.getConnection("jdbc:odbc:access","",""); Statement st=null; st
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
jdbc
that is used for database connectivity to hold the data returned by a select query. When we run a select query, it returns us the data with each row representing one logical group of data with a number of columns. JDBC ResultSet Example Stored
Jdbc
Jdbc  hi i want to search data from oracle data base bus i couldn't do it in my program i have to text field and save data with save button,data saved successfully but i unable to retrieve data, my code as follow private void
Jdbc
Jdbc  hi i want to search data from oracle data base bus i couldn't do it in my program i have to text field and save data with save button,data saved successfully but i unable to retrieve data, my code as follow private void
jdbc
jdbc  how to display database contents?   import java.sql....(); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost...(); ResultSet rs=st.executeQuery("select * from data"); while(rs.next
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
jdbc
how i can access Microsoft Access database by java program  how i can access Microsoft Access database by java program ? if any package or jar file required then please specify it. please give java source code for such database
jdbc
; Concurrency Database concurrency controls ensure that the transactions... In database, a lock is used to access a database concurrently for multiple users. This prevents data from being corrupted or invalidated when multiple users try
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
JDBC
retrieve the value from database into dropdown list using JDBC SQL 2005  How to retrieve the value from database into dropdown list using JDBC &...) in database and try the following code: <%@page import="java.sql.*"%> <
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
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
How i upload file and save that record in database using JSP?
How i upload file and save that record in database using JSP?  Hi All, I m the beginner in JSP and I want to upload the file and store that file and some other form data in MySQL database. Ex. There is one employee detail form
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
jdbc
the database using java with querys also   import java.sql.*; import... = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root...){ InsertAndRetrieveImage data=new InsertAndRetrieveImage(); } protected static
Export Database table to CSV File
Export Database table to CSV File In this tutorial, you will learn how to retrieve data from database and save it to CSV File. The Comma-separated values... a normal text file, and save the fetched data to it. There is no need to use any
How to save JCombobox Selected Item in to Access Database - Java Beginners
How to save JCombobox Selected Item in to Access Database  How to save JCombobox Selected Item in to Access Database  Hi Friend, Try...("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con =DriverManager.getConnection("jdbc:odbc
jdbc - JDBC
jdbc   i use pool connection for my application but whenever i insert data into database ,sometimes two copy of the data have been entered... of entering the two copy of data into database . please provide me the full code
Display Data from Database in JSP
, to show data from the database click on the link that calls another .jsp file named...;body> <h2>Data from the table 'stu_info' of database 'student'</h2...; <html> <head> <title>display data from
java database connection - JDBC
the data into the MS Access database and retrieve the data from the database table... =DriverManager.getConnection("jdbc:odbc:access"); pstm=connect.prepareStatement("insert into data...java database connection  sir i want to join my project with MS
add record to database - JDBC
add record to database  How to create program in java that can save record in database ?  Hi friend, import java.io.*; import java.sql....(); String url = "jdbc:mysql://localhost:3306/"; String db = "register
retrive data from database?
retrive data from database?  hellow i have a database sheet name as db1. it's contain sixty(60) sn,name ,rollno(primary key),father's name etc... from db1 and enter value in text box according there name,rollno and save
Full path of image to save it in a folder
Full path of image to save it in a folder  Sir ,I am trying to upload.... saving the file uploaded into the database, which would require the use of either JDBC or JPA, whichever is known to you. 2. saving the file in a folder
Oracle Database error - JDBC
Oracle Database error   String query11 = "SELECT product_code...); } rs11.close(); This is my code. I want to save Result set values in array... = DriverManager.getConnection("jdbc:mysql://localhost:3306/register", "root", "root"); Statement
parameter meta data - JDBC
in jdbc as well as the diffrent methods used in parameter meta data  ... the designated column's database-specific type name. int getPrecision(int column... on the designated column to succeed. For more information on JDBC visit to : http
JDBC Training, Learn JDBC yourself
depending on the Database up to 4 GB. It is a rich data type of JDBC..., database-driven applications. Prerequisite for JDBC course You must... JDBC Connection Pooling Accessing Database using Java and JDBC Learn how

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.