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



Home Answers Viewqa SQL updating a table in a database
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


raman
updating a table in a database
1 Answer(s)      4 years and 3 months ago
Posted in : SQL


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.

Advertisement
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
iBatis Update -Updating data of a table
iBatis Update -Updating data of a table   ... are updating table with an id as specified in our parameter and therefore... and essential feature for any database application. In this iBatis tutorial we have already
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
coding for updating profile
coding for updating profile  coding for updating profile
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
Copy Table in a MySQL Database
Copy Table in a MySQL Database     ... one table to another in a same MySQL database. To copy any table,  firstly... CopyOneTableToAnother Copy data from one table to another in a database! 2
Inserting Image in Database Table
Inserting Image in Database Table   ... to the MySQL database table.  Flow of the process : This program helps the user to insert an image in the MySQL database table. To insert
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
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... : This query shows data of a column in ascending order of the specific database table
Arrange a Column of Database Table
Arrange a Column of Database Table   ... that arrange the records of database table in descending order. The descending... with MySQL database. As soon as the connection gets established it takes a table
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
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
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
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
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
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
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
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
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
Count Rows from a Database Table
Count Rows from a Database Table       After creating a database table, if we want... need to pass a table name from the given database in the query and the rows
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
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
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
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: http://roseindia.net/jsp/servlet-jsp-data-list.shtml Thanks
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... to calculate the sum of specific column in database table. Here is the code of program
 

 

 

DMCA.com