You are on page 1of 3

import java.sql.

Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

public class sqldemo20{

public static void main(String args[]){

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

System.out.println("Connecting to Database");

Connection con=DriverManager.getConnection("jdbc:odbc:nespdsn");

System.out.println("Connected to Database");

String s="update Table1 set Name='Jack' where Name='John'";

PreparedStatement st=con.prepareStatement(s);

st.executeUpdate();

con.close();

catch(Exception e){

System.out.println("Connection error");

}
}

You might also like