import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class Jdbc4
{
public static void main(String[] args)throws ClassNotFoundException
{
// Loading & Register the Type-1 Driver Class(JdbcOdbcDriver). But this line is optional
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// Establishing the connection
try(Connection con=DriverManager.getConnection("jdbc:odbc:alt","system","manager"))
{
// Creating statement to execute query
Statement st=con.createStatement();
// Executing Query
int rc=st.executeUpdate("update emp set sal=sal+500");
System.out.println(rc+" row updated");
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class Jdbc4
{
public static void main(String[] args)throws ClassNotFoundException
{
// Loading & Register the Type-1 Driver Class(JdbcOdbcDriver). But this line is optional
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// Establishing the connection
try(Connection con=DriverManager.getConnection("jdbc:odbc:alt","system","manager"))
{
// Creating statement to execute query
Statement st=con.createStatement();
// Executing Query
int rc=st.executeUpdate("update emp set sal=sal+500");
System.out.println(rc+" row updated");
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
0 Comment to "Jdbc Program to update column data on 'emp' table."
Post a Comment