update database using two queries at a time

Ads
 

update database using two queries at a time

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);

Ads









Related Tutorials/Questions & Answers:
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
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
Advertisements
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
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
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
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
update mysql database
update mysql database  update mysql database
callable statement,stored procedure for insert data and also for update data into oracle database using jsp
callable statement,stored procedure for insert data and also for update data into oracle database using jsp  iam a fresher newbie to softparsing i... procedure for inserting data into oracle database as bind variable and same
Google Ranking Update for Spammy Queries
ranking update today for some spammy queries". This update was worldwide and many... in their ranking and disappeared from search results. This update targets spam queries... percent of English queries. It is a work in progress and will be completely
How to store multiple images in folder and images path in database at a time using jsp?
How to store multiple images in folder and images path in database at a time using jsp?  I wanna browse multiple images in one form and store them in one folder and their path into datrabase
Dynamically Update textbox from database
Dynamically Update textbox from database  I have a database as shown below.(database created using SQL Server 2005) name : george,simon address... with two text boxes. if I type something in one textbox, the corresponding value
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
JDBC Video tutorial - How to update Data in a MySQL Database?
the developers to write program, which connects to the MySQL database using pure... in Java for updating the data in a MySQL database table. We have used the update...) { System.out.println("Update value in Mysql database table!"); Connection con = null
Update Database from jsp
Update Database from jsp   I want to update my oracle database... UPDATE button the database field should be updated . I have a drop down menu...= null; st=conn.createStatement(); st.executeUpdate("UPDATE TEST_LINKS SET
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
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
total time calculator (starttime+endtime) in servlet USING DATABASE IN SQL2000 PLZ ANY ONE HELPME
total time calculator (starttime+endtime) in servlet USING DATABASE IN SQL2000 PLZ ANY ONE HELPME   <%-- Document : insertdate Created on : Jul 19, 2013, 3:48:28 PM Author : CG0T4908 --%> <
Set Time by using the Prepared Statement
the time in database table by using the PreparedStatement interface of java.sql... for setting the time in database table (child) by using the PreparedStatement... Set Time by using the Prepared Statement   
calculate difference between two time in jsp
calculate difference between two time in jsp  How to calculate difference between two dates
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
Read Excel data using JSP and update MySQL databse
Read Excel data using JSP and update MySQL databse  HOw to read excel data using JSP and update MySQl database
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
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
HQL Update Statement to update database table
HQL Update Statement to update database table HQL's update query statement is used to update the values of database rows. Though HQL is similar to SQL.... In this article we are testing an example to update the values of database table. See
how to update table using inner joins
how to update table using inner joins  how to update table using inner joins
Android using database
Android using database  How to Add,delete,modify the contact name,address,phone no into the database using android coding
update excel sheet using jsp::
update excel sheet using jsp::   Hi Sir,... I have a excel... given excel sheet and display it into another excel sheet using jsp" i am using 'session' to get the empid from one page to another jsp
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
Time limit for a question from database injsp
Time limit for a question from database injsp  Hellu sir i am creating a quiz app in jsp and have here two modules admin and user here admin enter... which is fetched from database after the time over i want to show the next
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java

Ads