update database using two queries at a time

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









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
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
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
update two frames at once
update two frames at once  How do I update two frames at once
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
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 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
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
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 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
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
using case in update statement
using case in update statement  i want to use case in update clause... syntax is not working for update stmt.my problem is update emp set case deptno... working but for first condition only update emp set deptno=(case when 10 then 20
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
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
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 --%> <
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
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
Update Records in Database
Update Records in Database       The Update Records in database is used to modify... The Tutorial illustrates an example from update record in database. In this Tutorial
Set Time by using the Prepared Statement
the time in database table by using the PreparedStatement interface of java.sql... This example helps us for setting the time in database table (child) by using... Set Time by using the Prepared Statement   
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 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
update data to mysql database through JTextField
update data to mysql database through JTextField  I am getting an error, when i am updating a data to mysql database through JTextField. Send me the code used to solve my error. public void update(){ try
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
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
how to update table using inner joins
how to update table using inner joins  how to update table using inner joins
Using insert update and delete in the same servlet
Using insert update and delete in the same servlet  How to write insert, update and delete coding in the same servlet
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
update a particular of mysql table using servlet
update a particular of mysql table using servlet  how to update a particular column for the entire table by taking requests from html form and update the particular column with out affecting other attribute values in the tuple
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
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
update
update  how can i update multiple records in database using jsp ,servlet and jdbc based on selection of checkbox in jsp
mysql run multiple queries at once
mysql run multiple queries at once  Running two MySQL queries at a time in PHP mysql_query
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
simple web appllication to insert, update or display from database - JSP-Servlet
simple web appllication to insert, update or display from database  hello sir i am using netbeans 5.5 ide with tomcat and oracle 9 i as database... in which we can insert, update or delete data from database. i can also display
How sql Queries possible in DAO without creating Database connections - Java Beginners
How sql Queries possible in DAO without creating Database connections  In DAO we are writting sql queries , how it is possible without creating and closing database connections
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:ADS_TO_REPLACE_1 Insert data into database Thanks
Android using database
Android using database  How to Add,delete,modify the contact name,address,phone no into the database using android coding
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 djile pak.java
using database - Development process
using database  i want to ask f we developed off line application then which database will be best for those application
database connectivity using mysql
database connectivity using mysql  java file: eg1.java package eg...: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver BUILD SUCCESSFUL (total time: 0 seconds) I am using Netbeans 5.5, mysql server 5.0, to get data from table
SQL Server row comparison using two tables
SQL Server row comparison using two tables  insertion process are completed in table1.string comparison using table2 to table1 if any changes in these tables and then upadated
Hibernate Update Query
by retrieving data from the underlying database using the hibernate. Lets first write a java class to update a row to the database. Create a java class: Here... Hibernate Update Query      
how to do two database tables in one page?
how to do two database tables in one page?  dear all: i want to show these two database tables in one page. one table on the left (dbtable.jsp) and the other on the right (table2.jsp). how can i do that with HTML? this is my
PreparedStatement using batch update - Java Beginners
PreparedStatement using batch update  How to execute different preparedStatement object using batch update(Java) Pls explain with the code... + db, user, pass); pst = con.prepareStatement("update data set address

Ads