Nov
29
Prepare all questions without any choice. Some of them will definitely be asked in your semester Exam either directly or indirectly.
Nov
29
Prepare all questions without any choice. Some of them will definitely be asked in your semester Exam either directly or indirectly.
Nov
29
Nov
29
Nov
19
// insfrm1.jsp
<html>
<body>
<form name=”f1″ method=”post” action=”dbins1.jsp”>
Roll No:<input type=”text” name=”rno”><br>
Student Name:<input type=”text” name=”snm”><br>
<input type=”submit” name=”s1″ Value=”Insert Record”>
</form>
</body>
</html>
//dbins1.jsp
<%@page import=”java.sql.*” %>
<%
String rno=request.getParameter(“rno”);
String snm=request.getParameter(“snm”);
try{
Class.forName(“com.mysql.jdbc.Driver”);
Connection con=DriverManager.getConnection(“jdbc:mysql://localhost:3306/sample”,”root”,””);
Statement stmt=con.createStatement();
String str=”insert into stud values(“+rno+”,'”+snm+”‘)”;
//out.println(str);
stmt.execute(str);
response.sendRedirect(“dbsel.jsp”);
//out.println(“Row inserted”);
}
catch(Exception e){
out.println(e);
}
%>
// dbsel.jsp
<%@page import=”java.sql.*” %>
<%
try{
Class.forName(“com.mysql.jdbc.Driver”);
Connection con=DriverManager.getConnection(“jdbc:mysql://localhost:3306/sample”,”root”,””);
Statement stmt=con.createStatement();
String str=”select * from stud order by rollno”;
//out.println(str);
ResultSet rs=stmt.executeQuery(str);
while(rs.next()){
out.print(rs.getString(“rollno”)+”—–“+rs.getString(“sname”)+”<br>”);
}
}
catch(Exception e){
out.println(e);
}
%>
Dec
04
NOTES OF BCA-V Subject: Java Programming and Dynamic Webpage Design (BCA-S302T)
Nov
17
import java.sql.*;
import java.io.*;
class TestDb9{
public static void main(String ard[]){
try{
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
Connection con=DriverManager.getConnection(“jdbc:odbc:BCADSN”,”system”,”ram”);
Statement stmt=con.createStatement();
//——————— TO DELETE RECORED——–
Console c=System.console();
String empno=c.readLine(“Enter Emp No want to update: “);
String mob=c.readLine(“Enter Mobile Number:”);
String qu=”update emp set mobile='”+mob+”‘ where empno=”+empno;
System.out.println(qu);
int num=stmt.executeUpdate(qu);
if(num==0){
System.out.println(“No such record found”);
}
// ———————— END —————————-
qu=”select * from emp order by empno”;
ResultSet rs=stmt.executeQuery(qu);
while(rs.next()){
System.out.println(rs.getString(“empno”)+”\t”+rs.getString(“ename”).toUpperCase()+”\t”+rs.getString(“mobile”));
}
rs.close();
stmt.close();
con.close();
}catch(Exception e){
System.out.println(e);
}
}
}
Nov
17
import java.sql.*;
import java.io.*;
class TestDb8{
public static void main(String ard[]){
try{
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
Connection con=DriverManager.getConnection(“jdbc:odbc:BCADSN”,”system”,”ram”);
System.out.println(“Con established”);
Statement stmt=con.createStatement();
System.out.println(“statement created”);
//——————— TO DELETE RECORED——–
Console c=System.console();
String empno=c.readLine(“Enter Emp No want to delete: “);
String qu=”delete from emp where empno=”+empno;
System.out.println(qu);
int num=stmt.executeUpdate(qu);
if(num==0){
System.out.println(“No such record found”);
}
// ———————— END —————————-
qu=”select * from emp order by empno”;
ResultSet rs=stmt.executeQuery(qu);
while(rs.next()){
System.out.println(rs.getString(“empno”)+”\t”+rs.getString(“ename”).toUpperCase()+”\t”+rs.getString(“mobile”));
}
rs.close();
stmt.close();
con.close();
}catch(Exception e){
System.out.println(e);
}
}
}
Nov
17
import java.sql.*;
import java.io.*;
class TestDb6{
public static void main(String ard[]){
try{
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
Connection con=DriverManager.getConnection(“jdbc:odbc:BCADSN”,”system”,”ram”);
System.out.println(“Con established”);
Statement stmt=con.createStatement();
System.out.println(“statement created”);
//——————— TO INSERT RECORED——–
Console c=System.console();
String empno=c.readLine(“Enter Emp No: “);
String empName=c.readLine(“Enter Emp Name: “);
String empMob=c.readLine(“Enter Emp Mobile: “);
String qu=”insert into emp values(“+empno+”,'”+empName+”‘,'”+empMob+”‘)”;
System.out.println(qu);
stmt.execute(qu);
System.out.println(“row inserted”);
// ———————— END —————————-
qu=”select * from emp order by empno”;
ResultSet rs=stmt.executeQuery(qu);
while(rs.next()){
System.out.println(rs.getString(“empno”)+”\t”+rs.getString(“ename”).toUpperCase()+”\t”+rs.getString(“mobile”));
}
rs.close();
stmt.close();
con.close();
}catch(Exception e){
System.out.println(e);
}
}
}