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);
}
%>
Nov
03
Do corrections in header files as per C++ Dev Turbo C++ editor
Feb
12
CUI Menu Based Java Program Sample
//—————–T45.java———————-
import java.io.*;
class T45{
public static void main(String args[]){
Console c=System.console();
int mn;
String ch;
do{
System.out.println(“\t\t :: Main Menu ::”);
System.out.println(“1- Get the Area of Square”);
System.out.println(“2- Get the Area of Rectangle”);
mn=Integer.parseInt(c.readLine(“Enter Your choice: “));
switch(mn){
case 1: {
//System.out.println(“case 1 executed”);
Square obj=new Square();
obj.area();
break;
}
case 2:{
//System.out.println(“case 2 executed”);
Rect obj=new Rect();
obj.area();
break;
}
default: System.out.println(“Invalid Choice”);
}
ch=c.readLine(“Do you want to continue(y/n): “);
}while(ch.equalsIgnoreCase(“y”));
}
}
//—————–Square.java———————-
import java.io.*;
class Square{
int a, area;
Console c=System.console();
void area(){
a=Integer.parseInt(c.readLine(“Enter length of square: “));
area=a*a;
System.out.println(“SQ Area is: “+area);
}
}
//—————–Rect.java———————-
import java.io.*;
class Rect{
int n1,n2, area;
Console c=System.console();
void area(){
n1=Integer.parseInt(c.readLine(“Enter width of rect: “));
n2=Integer.parseInt(c.readLine(“Enter height of rect: “));
area=n1*n2;
System.out.println(“Rect Area is: “+area);
}
}
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);
}
}
}