jdbc program

jdbc program

  1. Write a program to update the salaryRs.6000/- for an employee name like â??P. Ramuâ?? using prepared statement.
View Answers

April 10, 2012 at 3:43 PM

import java.sql.*;

public class JdbcPreparedstatementUpdate {

  public static void main(String args[]) {

  Connection con = null;
  PreparedStatement pst = null;

  String url = "jdbc:mysql://localhost:3306/";
  String db = "test";
  String driver = "com.mysql.jdbc.Driver";
  String user = "root";
  String pass = "root";

  try {
  Class.forName(driver);
  con = DriverManager.getConnection(url + db, user, pass);

  pst = con.prepareStatement("update employee set salary=? where name=?");

  pst.setInt(1, 6000);
  pst.setString(2, "P.Ramu");

  pst.executeUpdate();


  pst.close();
  con.close();

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

April 10, 2012 at 3:51 PM

import java.sql.*;

public class JdbcPreparedstatementUpdate {

  public static void main(String args[]) {

  Connection con = null;
  PreparedStatement pst = null;

  String url = "jdbc:mysql://localhost:3306/";
  String db = "test";
  String driver = "com.mysql.jdbc.Driver";
  String user = "root";
  String pass = "root";

  try {
  Class.forName(driver);
  con = DriverManager.getConnection(url + db, user, pass);

  pst = con.prepareStatement("update employee set salary=? where name like ?");

  pst.setInt(1, 6000);
  pst.setString(2, "P.Ramu%");

  pst.executeUpdate();


  pst.close();
  con.close();

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









Related Tutorials/Questions & Answers:
jdbc program
jdbc program   Write a program to update the salaryRs.6000/- for an employee name like â??P. Ramuâ?? using prepared statement
Jdbc and Socket Program - JDBC
Jdbc and Socket Program  Sir, I would like to get a program i... in a database.Now we create another program 4 client-server such that the sever's database is updated everytime we enter username and password in client program
Advertisements
execution of a jdbc program
execution of a jdbc program  how to execute a servlet program that..uses a jdbc driver (i.e. using mysql-connector -java )to connect to mysql in windows *PLS provid the execution steps in detail THANK YOU
java program - JDBC
of tables as fields, in this case i have three tables, i need a java program..., Please give details to solve the problem. For read JDBC connection to visit.... http://www.roseindia.net/jdbc/jdbc-mysql/MysqlConnect.shtml
Java Program - JDBC
Java Program  A java Program that display data from a Table in MSAccess in JTable using JFrame  Hi Friend, Try the following code...("jdbc:odbc:access"); String sql = "Select * from data"; Statement stmt
JDBC Oracle program
JDBC Oracle program  Here is my code: import java.sql.*; public class Tyagi { public static void main (String args[])throws SQLException... = DriverManager.getConnection("jdbc:oracle:thin:@localhost:8080:oracle", "System", "System
Java Program - JDBC
("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:access... = DriverManager.getConnection("jdbc:odbc:access"); Statement st
Java Program - JDBC
Java Program  A java program that display in in a table in JTable
Java Program - JDBC
Java Program  A java program that display data in textfields and having buttons for move next, move previous,move last,move first using JFrame
jdbc connection to java program code - JDBC
jdbc connection to java program code  i want a simple java program that which communicates with oracle database like creating table,insert values and update records in database and show in program output? please take a simple
Jdbc Program for building Student Information Database - JDBC
Jdbc Program for building Student Information Database  import...;sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc...=DriverManager.getConnection("jdbc:odbc:Avishek"); s1=tf1.getText
How Jdbc program can be run??
How Jdbc program can be run??  import java.sql.*; import java.util.... { Connection conn=DriverManager.getConnection("jdbc:odbc:advdsn1","student","myself... created successfully and when i compiled this program then it compiled successfully
regarding connectivity program only - JDBC
regarding connectivity program only  can u give me code regarding... = "jdbc:mysql://192.168.10.211:3306/"; String db = "amar"; String driver... for more information. http://www.roseindia.net/jdbc
how to run jdbc program in linux-ubuntu?
how to run jdbc program in linux-ubuntu?   how to run jdbc program in linux-ubuntu
regarding connectivity program only - JDBC
regarding connectivity program only  can u give me code regarding .. that i had created student data base with his name and subject marks resp ... i use html in front end ...that there r options like 1.name---------- 2.sub1
how to run jdbc program in linux-ubuntu?
how to run jdbc program in linux-ubuntu?  how to run jdbc program in linux-ubuntu?   hi firstly download the jdk on your system using... to compile java program javac prog.java java prog
write a program for complete JDBC based application
write a program for complete JDBC based application   thank you sir giving answer for my question. my another question is: Write a complete JDBC... and the program should have the facilities of Adding, Modifying, Viewing and Deleting
how to run jdbc in jsp program - JSP-Servlet
how to run jdbc in jsp program  i want to use sql server 2005 in jsp program to store data.i know how to run simple program but this program i tried my best i am not able to do so.please give me the answer of this as soon
program
program  program of jdbc using ms access for creating table
jdbc
jdbc   how to write program to save data and retrieve data from the form in Java
Jdbc
Jdbc  A java program with jdbc connectivity with insert,delete,update options for name,regno,mark1,mark2,total
program
= DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:satya","scott","tiger... = DriverManager.getConnection ("jdbc:mysql://localhost:3306/test","root",""); Statement
program
program  any program of hotel or school management
program
program  write a javascript program to create a application form with validation
program
program  write a html program in show table and this word in box
program
program  write a program different between to dates in terms of days in java
hi, Everyone ,i'm learning jdbc, i got an nullpointerexception when execute this program.
hi, Everyone ,i'm learning jdbc, i got an nullpointerexception when execute this program.   ConnectionProvider.java import java.util.*; import... class=oracle.jdbc.driver.OracleDriver url=jdbc:oracle:thin:@localhost:1521:xe user
online quiz program coding using jsp, jdbc odbc connection with ms. access.. Thank you.
online quiz program coding using jsp, jdbc odbc connection with ms. access.. Thank you.  please provide online quiz program coding using jsp, jdbc...").newInstance(); Connection connection = DriverManager.getConnection("jdbc:mysql
Program
=DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root","root";;); Statement st
program
program  WAP a java program to form 1/2+3/4+5/6+7/8 series
program
program   Write a program to find the difference between sum of the squares and the square of the sums of n numbers
program
program  write a program reversee a string. input-hi this is roseindia output-roseindia is this hi
program
program  develop a servlet to insert the data in the database from our program in the table stored in the database
program
program   An old-style movie theater has a simple profit program. Each customer pays $5 per ticket. Every performance costs the theater $20, plus $.50 per attendee. Develop the program calculateTotalProfit that consumes
program
program  write a java program to input a no. and print wheather the no. is a special no or not. (special no. are those no whose factorial of the sum of digit of the no is same as the original
program
program  Develop the program calculateCylinderArea, which accepts radius of the cylinder's base disk and its height and computes surface area of the cylinder
program
program  explanation of program on extending thread class   Hi Friend, Please go through the following link:ADS_TO_REPLACE_1 Java Threads Thanks
program
program  Develop a program that computes the distance a boat travels across a river, given the width of the river, the boat's speed perpendicular to the river, and the river's speed. Speed is distance/time, and the Pythagorean
program
program  how to improve programming skills plss tell some tips..i am understanding concepts but unable to write program so,pls give some guideness plsss
Program
Program  a program to prove that default constructor of super class is available to subclass by default. Define a parameterize constructor for super class to store name = â??Tommyâ?? age=â??23â?? and call this constructor
Program
Program  a program to create two classes Commercial and Domestic. Override the method calculatebill() of Commercial class(Rs.8 per unit) into Domestic class(Rs 6 per unit) to compute electricity bill for both classes
program
program  no i want a program that shows how merge sort algorithm works in graphical representations like numbers are taken in circles and computation... in rectangles or circles wat ever it may be. the theme of program is to show algorithm
program
program  . Develop a program that accepts an initial amount of money (called the principal), a simple annual interest rate, and a number of months will compute the balance at the end of that time. Assume that no additional
program
program  Write a JSP Program, which displays a web page containing the name of the Courses, Courses being offered currently, number of students enrolled in each course, new courses to be offered, eligibility criteria for taking
program
program  i want a progra in java to print a sentence in alphabetic order, taking the input from the user.the program should writen without using the array for example : if input= this is a cat then output sould = a cat
program
program  Utopias tax accountants always use programs that compute income taxes even though the tax rate is a solid, never-changing 15%. Define the program calculateTax which determines the tax on the gross pay. Define
program
program  Write a JSP Program, which displays a web page containing two web links one for your profiling and other for the schedule of theory of practical classes of your Batch. When one click on link for getting your profile
program
program  Write a program to print details of a week for a particular day using array of objects Integer and String. OUTPUT: First Day of Week is Monday Second Day of Week is Tuesday Third Day of Week is Wednesday Forth Day
JDBC
JDBC  why we use batch in jdbc
jdbc
jdbc  display the records using index in jdbc

Ads