updating a table in a database

give me complete source code in java to execute the sqlquery such that
(update table_name set phone no=? where cous_id=?). or in simple way give me source code to update my table in MsAccess with new values.
View Answers

July 29, 2010 at 12:05 PM

Hi Friend,

Try the following code:

import java.sql.*;
import java.util.*;
class UpdateTable{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.print("Enter Name: ");
String v1=input.nextLine();
System.out.print("Enter Address: ");
String v2=input.nextLine();
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:access");
Statement st = con.createStatement();
int c = st.executeUpdate("update data set name='"+v1+"',address='"+v2+"' where id=4");
System.out.println("1 row affected");
st.close();
con.close();
}


catch(Exception e){
System.out.println(e);
}

}

}

Thanks









Related Tutorials/Questions & Answers:
updating a table in a database - SQL
updating a table in a database  give me complete source code in java to execute the sqlquery such that (update table_name set phone no=? where cous_id=?). or in simple way give me source code to update my table in MsAccess
Lock while inserting/updating database in multithreaded.
Lock while inserting/updating database in multithreaded.  Hi, I am having a multithreaded process which replicates the data from many table to one... inserting/updating to database. I dont know what is the issue but it was never
Advertisements
updating an access database with visual basic 2010
updating an access database with visual basic 2010  I am building a program in visual basic 2010 that connects to an access database. I was wondering if you could help me figure out the code for the save button. When
Updating Ms Access Database using jsp - JSP-Servlet
Updating Ms Access Database using jsp  Hi I am new to jsp and I am trying to update a record in an access database. I only want to update part... a table product(prod_id,prod_name,quantity,price) and try the following code
inserting dropdown values into database table
inserting dropdown values into database table   hi i want to insert dropdown values into a database table by using jsp
Designing a Database with a junction table or without it?
Designing a Database with a junction table or without it?  Designing a group of table with, where many tables reference single parent table. In that case is it a better option to create a junction table to maintain
iBatis Update -Updating data of a table
iBatis Update -Updating data of a table   ...; iBatis Update Query Here in our example we are updating table with an id... and essential feature for any database application. In this iBatis tutorial we have already
redeploy project update database table
redeploy project update database table  **Dear Sir, i am using Hibernate 3.3 and spring 3.0 and mysql database. Now while redeploying project In tomcat 6 i want to run a sql query Thanks for your wise comments
Retrieving the Image from a database Table
Retrieving the Image from a database Table Consider a case where we want... to retrieve the image from the database table. You can do it very easily after... from the database table our java program need to make a connection
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
Copy Table in a MySQL Database
Copy Table in a MySQL Database     ... you in copying one table to another in a same MySQL database. To copy any table...). This database has both the tables (Copyemployee and employee table
Inserting Image in Database Table
Inserting Image in Database Table   ... to the MySQL database table.  Flow of the process : ADS_TO_REPLACE_1 This program helps the user to insert an image in the MySQL database table
Description of Database Table
Description of Database Table     ... about the database table. As we all know that, table has some specific information... by the database. By using a simple query we can get all information about the table
Arrange a Column of Database Table
Arrange a Column of Database Table   ... for arranging the data of database table in ascending order. Firstly we should know... database table. ADS_TO_REPLACE_2 The SELECT specifies the table columns
Arrange a Column of Database Table
Arrange a Column of Database Table   ... that arrange the records of database table in descending order. The descending...; to arrange the records of database table in descending order. The SELECT
data insertion from xml file to database table
data insertion from xml file to database table  Hi all, I have data in the XML file. I need to insert it into table in the database using servlet. so please reply me . ThankYou
WANNA IMPORT RAINBOW TABLE IN MYSQL DATABASE
to import rainbow table in mysql database thanks...WANNA IMPORT RAINBOW TABLE IN MYSQL DATABASE  hello, i have a website and i have rainbow table uploaded on my server. this is multipart rainbow
Deleting a Table from Database
Deleting a Table from Database   ... database. But how we can delete the table using java methods and API. In this section we are describing, how to delete a table from database using java methods
how to create database and table using jsp
how to create database and table using jsp  hi frnds...., i want to create database and table in mysql using jsp.... i have an registration form(name,sex,address,phone and so on ... ) i want to create individual table in mysql
Copy One Database Table to Another
Copy One Database Table to Another       In this section, you will learn to copy one database table to another database table. That means we copy one table to a different table
insert user session into other oracle database table
insert user session into other oracle database table   hello i am a doing my project in jsp-servlet. i have doubt that when a user login to his... table. with user id i also want to insert date and current time in to database
Retrieve multiple data from database into Table.....
Retrieve multiple data from database into Table.....   hi........... I want to Retrieve multiple data from database into Table but i am not able... database i have attributes pH, phosphate, ....... month, year......... so its
php csv file uploding into mysql database table.
php csv file uploding into mysql database table.  hai friends, i... fields. i have one mysql database table with two files fields, when ever i am uploding csv file, i want to fetch the datas in corresponding fields in table. can
Displaying database table on the windows screen in real time.
Displaying database table on the windows screen in real time.  Problem statement... I have a database table which is running on a remote host .I need to write a program to display this table in a windows form or on a html page
Delete a Column from a Database Table
Delete a Column from a Database Table   ... to delete a column from a database table. We are not going to create a new table... the already created table in the specific database. Now if we want to delete
Count Rows from a Database Table
Count Rows from a Database Table       After creating a database table, if we want... established we need to pass a table name from the given database in the query
how to display a table from database using servlet
how to display a table from database using servlet  how to display a table with values from servletpage   Hi Friend, Please go through the following link:ADS_TO_REPLACE_1 http://roseindia.net/jsp/servlet-jsp-data
Fetch user records from a table in database
Fetch user records from a table in database  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai... the field table. Actually they are separated by comma. I want to take the values
Inserting values into a database table of selected DropDown in jsp.
Inserting values into a database table of selected DropDown in jsp.  http://www.roseindia.net/answers/viewqa/Ajax/15250-DropDown-in-ajax+jsp.html... selected india and then goa. I want to insert it to a table which has two fields
Inserting values in MySQL database table
Inserting values in MySQL database table       After making the table in the database, we need... insert values in the MySQL database table. We know that tables store data in rows
Make Unique Column in Database Table
Make Unique Column in Database Table   ... a unique key in a column of a database table. While declaring unique key...; }   } } Database Table: Student Table Stu_id
Insert Serialized Object into Database Table
Insert Serialized Object into Database Table In the previous tutorial, you... into database table, deserialize it after fetching it from database table... StudentDetails class and inserting it into a database table serializationtest
Sum of Column in a Database Table
Sum of Column in a Database Table   ... of specific column data in the database table. Consider an example of any... we going to do is to establish the connection with MySQL database by using
Select data from Table in Database
Select data from Table in Database   ... the selected data from table in database. The select query in the database retrieve...; in simple select statement is given below select column name from table;ADS
applet connected to table in MS Access database
applet connected to table in MS Access database   i have connected my java code with the MS access database and this is my code, can anyone tell me how to show the table in an applet...pls import java.sql.
Retrieving value from multiple table in database
Retrieving value from multiple table in database  Hi fnds, I want to maintain the financial database of 20 users for 1 year and update the details... created 12 tables with table name - month1,month2,....,upto month12.. each table
Extracting table from Access Database to Servlet
Extracting table from Access Database to Servlet  Sir, I have a table with 4 field deptid, headid, normalexpend and projectexpend. Now I have to display a consolidated data where sum of normal_expend under particular head
Delete database Table through hibernate and Spring
Delete database Table through hibernate and Spring  Hi, I am using... once without repetation,or Detete table after data is fetched. Here...(); return info; } } Here is class for Table(Info
display data from a table in Access Database in a HTML page
display data from a table in Access Database in a HTML page  how to display data from a table in Access Database in a HTML page in a Java Program
Remove Unique Column in Database Table
Remove Unique Column in Database Table   ... unique field of the particular column in a database table.  We know... from the particular column in the database table. In this query we will give table
Storing records of a file inside database table in java
Storing records of a file inside database table in java  Here is my requirement, I have a file which contains some number of records like... the records inside the database except headings (Here sid,sname,age are headings
storing records which of a file into a table of mssql database
storing records which of a file into a table of mssql database  I have a requirement like this, A file contains some records with headers same as column names of a table. I have to store those records into a table
How to search the table name in MS SQL Database 2005 from application
How to search the table name in MS SQL Database 2005 from application  How to search the table name in MS SQL Database 2005 from application from our helpdesk application? application might be in html
i want to protect mysql database table which user can not view to table and can not copy my table till then us
i want to protect mysql database table which user can not view to table and can not copy my table till then us  i want to protect mysql database... backup of database. if user and programmer want to export and import to table
coding for updating profile
coding for updating profile  coding for updating profile
Deleting All Rows from a Database Table
Deleting All Rows from a Database Table   ... database table, now we have to delete all the rows from the table. This section describes for deleting all rows from a specific database table. Deleting all rows
i want to protect mysql database table which user can not view to table and can not copy my table till then us
i want to protect mysql database table which user can not view to table and can not copy my table till then us  i want to protect mysql database... backup of database. if user and programmer want to export and import to table
Retrieve database from the table dynamically in jsp from oracle using servlet
Retrieve database from the table dynamically in jsp from oracle using servlet  Sir, I have created a table in oracle using eclipse, and added few columns dynamically. I want to retrieve the table with all columns dynamically
Creating a Database Table
Creating a Database Table      ...; Table: A table is basic component of database (DB) that has number of rows... to create a database table by using java file. Brief description given below
Deleting All Rows From the database Table
From the database Table      ... helps us to write on the browser. To delete all the rows from our database table... for deleting all the rows in the database table. This query will be fired