Ajp Pra 19
Ajp Pra 19
DOP: DOS:-
Q.1)write the program to update rows of student table from msbte database
using mysql database server
Code:
import java.sql.*; public class Pr19pc1
try
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/VRD","root","root");
con.close();
}
catch(Exception e)
System.out.println(e);}
Output :-
2. write the output of following jdbc code
Code:
import java.sql.*;
try
Class.forName("com.mysql.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/VRD","root","root");
//3 specifies the third parameter(3rd ? symbol) in the query int i=stmt.executeUpdate();
catch(Exception e)
{
System.out.println(e);}
Output:
Exercise:-
catch (SQLException s) {
System.out.println("sql error");
}}
Output:
2.Develop a program to update a record in database table. Code:
{ try
Connection con =
System.out.println(r.getInt(1)+"\t"+r.getString(2)+"\t"+r.getInt(3)+"\t"
+r.getInt(4));
System.out.println(rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getInt(3)+ "\t"+rs.getInt(4));
}
s.close(); con.close();
catch (SQLException s)
System.out.println("sql error");