Home Answers Viewqa SQL update database using two queries at a time

 
 


sharmila
update database using two queries at a time
1 Answer(s)      10 months ago
Posted in : SQL

String sql="insert into employee values(emp_seq.nextval,\'"+ename+"\',\'"+eadd+"\',\'"+ephone+"\',\'"+email+"\',\'"+department+"\',"+Integer.parseInt(ebpay)+",20,0)";

stm.executeUpdate(sql);

String sql1="insert into appusers values(emp_seq.nextval,\'"+ename+"\')";

stm.executeUpdate(sql);

---this is the code i have.But i need to perform insertion in both the tables i.e employee and appusers at the same time as i need the same sequense value in both the tables.

plzz help

View Answers

July 5, 2012 at 11:36 AM


You can execute two queries with two different Statement object in the following way. Another thing, you have executed same query twice in your code.

Statement st1=conn.createStatement();

String sql="insert into employee values(emp_seq.nextval,'"+ename+"','"+eadd+"','"+ephone+"','"+email+"','"+department+"',"+Integer.parseInt(ebpay)+",20,0)";

st1.executeUpdate(sql);

Statement st2=conn.createStatement();

String sql1="insert into appusers values(emp_seq.nextval,'"+ename+"')";

st2.executeUpdate(sql1);









Related Pages:
update database using two queries at a time
update database using two queries at a time  String sql="insert... can execute two queries with two different Statement object in the following way... to perform insertion in both the tables i.e employee and appusers at the same time
queries
queries  class one having the static variable and method....... we extend class one to class two ..... In clas two if we create a object for class one then we can access the static variable that present in class one
update
update  how can i update multiple records in database using jsp ,servlet and jdbc based on selection of checkbox in jsp
two select queries shouldn't depend on each other
two select queries shouldn't depend on each other   i want to write two select queries such that both queries shouldn't depends on each other .or how can i re-write this query? can i write this without using where
mysql run multiple queries at once
mysql run multiple queries at once  Running two MySQL queries at a time in PHP mysql_query
Update value of database using hibernate.
Update value of database using hibernate.  How to update value of database using hibernate?   Hibernate provides facility to update... this by setting the value and calling the update method. session.update(employee
textfields and update - SQL
textfields and update  how can i retrieve a table from a database and put in on the textfields using jdbc?and at the same time update the items on the database
Update Database Table using JDBC in JSP
Update Database Table using JDBC in JSP       This example shows how to update the existing  record of mysql table using jdbc connectivity in the jsp page
textfields and update - SQL
to the textfields using jdbc?and at the same time update the items... basis u want to update database? can u clarify? Thanks Rajaniakant  Hi friend, Code to update record retieve at the Same time: Some
Update Record using Prepared Statement
JDBC: Update Record using Prepared Statement In this section, you will learn how to update row using Prepared Statements. Update Record  ... statement. Update record is most important operation of database. You can update one
Statement Batch Update
or updates simultaneously in the database. In this process multiple SQL queries are added in the Statement object and update the records of database simultaneously... at a time. Firstly we are going to establish the connection with MySQL database
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
how to update checkbox list in database
how to update checkbox list in database  Issues: i am using... to update one by one but it's not updating by using below code .it's not adding... in the database below logic is working fine by using insert command
How to calculating time difference bewteen two countries using country name?
How to calculating time difference bewteen two countries using country name?  How to calculate the time difference between two countries. Example if i pass India and America, then the program should return the time difference
update two frames at once
update two frames at once  How do I update two frames at once
Update value
Update value  How to update value of database using hibernate ?   Hi Samar, With the help of this code, you will see how can update database using hibernate. package net.roseindia.DAO; import
Read data from excel file and update database using jsp
Read data from excel file and update database using jsp  read data from excel file and update database using jsp Hi, I am using a MySQL database... upload excel file and update database using JSP ? Thanks in Advance
JPA Named Queries
JPA Named Queries       In this section, you will know about the JPA Named Queries...;updateStudentRecords", query="UPDATE Student st SET st.sname= ?1 WHERE st.sname= ?2"
update database
update database  hi.. i want to know how the valuesof database can... that can be done there then by pressing the update buutton the value can be updated to database
Java Queries
the textfields, button and labels on the frame using setBounds() method. import
Update statement
Update statement  I create a access database my program When I click add button bata are adds to the my data base but when i click update button my database is not update I write this program using 3 differfnt notepad pages MY
data update
the changes into the same table. Consider this is a huge database we should fetch the data and edit it based on subjectcode(varchar)this should be done using jsp... edit/update data and saved them into that table again
JDBC: Batch Update Example
update of records using JDBC API. Batch Update : When you want to update... cause communication overhead. So to reduce time and cost, we use batch update concept. We can update multiple rows using single connection in batch update
data update
the changes into the same table. Consider this is a huge database we should fetch the data and edit it based on subjectcode(varchar)this should be done using jsp
data update
the changes into the same table. Consider this is a huge database we should fetch the data and edit it based on subjectcode(varchar)this should be done using jsp
data update
the changes into the same table. Consider this is a huge database we should fetch the data and edit it based on subjectcode(varchar)this should be done using jsp
data update
the changes into the same table. Consider this is a huge database we should fetch the data and edit it based on subjectcode(varchar)this should be done using jsp
data update
the changes into the same table. Consider this is a huge database we should fetch the data and edit it based on subjectcode(varchar)this should be done using jsp
data update
the changes into the same table. Consider this is a huge database we should fetch the data and edit it based on subjectcode(varchar)this should be done using jsp
data update
the changes into the same table. Consider this is a huge database we should fetch the data and edit it based on subjectcode(varchar)this should be done using jsp
Hibernate update Query
in hibernate. In hibernate update query updates the data of the database table when... and updates using the update query and executeUpdate() method of Query. The value...Hibernate update Query In this tutorial you will learn about an update query
Update Records in Database
Update Records in Database       The Update Records in database is used to modify... from update record in database. In this Tutorial, the code run a select query
Oracle Database - Insert System Time
Oracle Database - Insert System Time  Hi I want to insert only system time dynamically using a statement but not a prepared statement into Oracle Database please suggest me any code
update mysql database
update mysql database  update mysql database
3 queries on java class
3 queries on java class  Hey. I need to do 3 queries on same class ( JAVA) One is to populate the combobox, the another one to populate tje jlist and the last one to use on button to open a file from database (BLOB) Can some
How to update table in Hibernate
How to update table in Hibernate  Hi, I have a table in database that has two fields in it. Student Name and ID, can anyone explain me how to update these tables in Hibernate. Thanks.   Update table query in Hibernate
how update JTable after adding a row into database
how update JTable after adding a row into database  J have two... in JTable, and it's OK, but after adding a row into database table does't update. How update JTable after adding a row into database? package djilepak.javaclss.for
JPA Native Queries, JPA Native Queries Tutorials
JPA Native Queries       In this section, you will know about the jpa native queries and how to use native query in your JPA application.  JPA Native Queries: JPA native
doubts for sub queries in mysql
doubts for sub queries in mysql  how to display the details of one table by checking the conditions in the next table using some condition eg., mysql> select * from student where number=(select id from studentpersonal where
Time table generation
in database depends upon the number of courses we have in time table. Accordingly, we...Time table generation  Hi I am 3rd year bca student i want create time table generator for my project.i am going to create it as school time table
PHP SQL Query
application. Most of the applications need to interact with database to store, update and fetch the data. This interaction is made executing Sql queries. To understand..., connection from database is created using mysql_connect("hostName", "
Blob update in hibernate
Blob update in hibernate  Hi , I wanted to upload a blob into mysql database using hibernate. Could you please help me . Thanks in advance, Satchidanand Mohanty
Spring SimpleJdbcTemplate update
are going to update the database table row using update method . We are using...Spring SimpleJdbcTemplate update This section is about update method using SimpleJdbcTemplate  to update records . The update method is beneficial
store the employee ID,name,login time and logout time of the employee in database
time of the employee along with the time difference between these two in separate columns in a database table..the login and logout time has been stored...store the employee ID,name,login time and logout time of the employee
hibernate update problem
hibernate update problem  HI, I integrated the struts and hibernate and wrote the following query in the databean to update the user table login time SessionFactory sessionFactory = (SessionFactory)context.getAttribute
database
database  Create tables EMP, and DEPT, Write SQL queries for the following : Display each employeeâ??s name and date of joining. Display employees... hired in 1981 from EMP table. Update the salary of all the employees to Rs. 10,000
MySQL PHP Update
(0.00 sec) updating table data using php:  The PHP include the update mysql...;Error in selecting the database:".mysql_error()); $sql="update... MySQL PHP Update      
how to make JTable to add delete and update sql database table
how to make JTable to add delete and update sql database table  Hello all I want to know how to make JTable to act actively to add delete and update database table. i am struck ed here from long time please help me
Mysql Time Function
of queries that return you the different current date, current time, From Unix... to return the current time of a table in database.  mysql> SELECT... of the specified time using "HOUR(time)" mysql> SELECT HOUR('02:02:14
Update after delete
..... and i am deleting 3 record using id column of database mysql so now id will be 1,2,4,..... now i want to reassign id column 1,2,3,.... using ResultSet...Update after delete  sir,i am working on online examination project

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.