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);
}
}
}
Nov
17
import java.sql.*;
import java.io.*;
class TestDb5{
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”);
String qu=”select * from emp”;
ResultSet rs=stmt.executeQuery(qu);
while(rs.next()){
System.out.println(rs.getString(“empno”)+”\t”+rs.getString(“ename”).toUpperCase()+”\t”+rs.getString(“mobile”));
}
}catch(Exception e){
System.out.println(e);
}
}
}
Nov
17
import java.sql.*;
import java.io.*;
class TestDb4{
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”);
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”);
}catch(Exception e){
System.out.println(e);
}
}
}
Nov
17
import java.sql.*;
import java.io.*;
class TestDb3{
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”);
Console c=System.console();
String qu=c.readLine(“Enter insert sql : “);
//qu=”insert into emp values(3,’uu’,’70070′)”;
System.out.println(qu);
stmt.execute(qu);
System.out.println(“row inserted”);
}catch(Exception e){
System.out.println(e);
}
}
}
Nov
17
import java.sql.*;
import java.io.*;
class TestDb2{
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”);
/*Console c=System.console();
String qu=c.readLine(“Enter sql for table: “);*/
String qu=”insert into emp values(3,’uu’,’70070′)”;
System.out.println(qu);
stmt.execute(qu);
System.out.println(“row inserted”);
}catch(Exception e){
System.out.println(e);
}
}
}
Nov
17
import java.sql.*;
import java.io.*;
class TestDb1{
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”);
Console c=System.console();
String qu=c.readLine(“Enter sql for table: “);
System.out.println(qu);
stmt.execute(qu);
System.out.println(“table sql executed”);
}catch(Exception e){
System.out.println(e);
}
}
}
Nov
17
import java.sql.*;
class TestDb{
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”);
String qu=”drop table emp”;
stmt.execute(qu);
System.out.println(“table dropped”);
qu=”create table emp(empno number(2),ename varchar2(50),mobile varchar2(20))”;
System.out.println(qu);
stmt.execute(qu);
System.out.println(“table created”);
}catch(Exception e){
System.out.println(e);
}
}
}
Sep
18
//Applet with Arc
import java.applet.*;
import java.awt.*;
/*
<Applet code=”Ap6.class” width=”400″ height=”400″></applet>
*/
public class Ap6 extends Applet{
public void init(){
setBackground(Color.red);
setForeground(Color.yellow);
}
public void paint(Graphics g){
g.fillArc(130,110,140,140,0,-180);
}
}
//Applet with Animation-1
import java.applet.*;
import java.awt.*;
/*
<Applet code=”Ap7.class” width=”400″ height=”400″></applet>
*/
public class Ap7 extends Applet{
public void init(){
setBackground(Color.red);
setForeground(Color.yellow);
}
public void paint(Graphics g){
for(int i=0;i<=310;i+=10){
repaint();
g.fillOval(i,20,90,90);
try{
Thread.sleep(1000);
}catch(InterruptedException e){
}
}
}
}
//Applet with Animation-2
import java.applet.*;
import java.awt.*;
/*
<Applet code=”Ap8.class” width=”400″ height=”400″></applet>
*/
public class Ap8 extends Applet{
public void init(){
setBackground(Color.red);
setForeground(Color.yellow);
}
int x=0;
int y=20;
public void paint(Graphics g){
if(x<=310){
x=x+5;
}else{
y=y+5;
}
g.fillOval(x,y,90,90);
try{
Thread.sleep(100);
}catch(InterruptedException e){
}
repaint();
}
}
//Applet with Mouse Event-1
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*
<Applet code=”Ap9.class” width=”400″ height=”400″></applet>
*/
public class Ap9 extends Applet implements MouseListener{
public void init(){
addMouseListener(this);
}
public void mouseExited(MouseEvent e){
System.out.println(“mouseExited”);
}
public void mouseEntered(MouseEvent e){
System.out.println(“mouseEntered”);
}
public void mouseReleased(MouseEvent e){
System.out.println(“mouseReleased”);
}
public void mousePressed(MouseEvent e){
System.out.println(“mousePressed”);
}
public void mouseClicked(MouseEvent e){
System.out.println(“mouseClicked”);
}
public void paint(Graphics g){
}
}
//Applet with Mouse Event-2
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*
<Applet code=”Ap10.class” width=”400″ height=”400″></applet>
*/
public class Ap10 extends Applet implements MouseListener{
public void init(){
addMouseListener(this);
}
public void mouseExited(MouseEvent e){
}
public void mouseEntered(MouseEvent e){
}
public void mouseReleased(MouseEvent e){
}
int x,y;
public void mousePressed(MouseEvent e){
x=e.getX();
y=e.getY();
showStatus(x+”,”+y);
repaint();
}
public void mouseClicked(MouseEvent e){
}
public void paint(Graphics g){
g.drawString(x+” , “+y,x,y);
}
}
Sep
15
//:APPLET LIFE CYCLE EXAMPLE:
import java.applet.*;
import java.awt.*;
/*
<Applet code=”Ap.class” width=”300″ height=”300″></applet>
*/
public class Ap extends Applet{
public void init(){
System.out.println(“init() called”);
}
public void start(){
System.out.println(“start() called”);
}
public void paint(Graphics g){
System.out.println(“paint() called”);
}
public void stop(){
System.out.println(“stop() called”);
}
public void destroy(){
System.out.println(“destroy() called”);
}
}
//:APPLET CODE-1:
import java.applet.*;
import java.awt.*;
/*
<Applet code=”Ap2.class” width=”300″ height=”300″></applet>
*/
public class Ap2 extends Applet{
public void init(){
//setBackground(Color.red);
setBackground(new Color(100,255,0));
}
public void paint(Graphics g){
g.drawString(“HELLO”,100,100);
g.drawLine(50,50,200,200);
}
}
//:APPLET CODE-2:
import java.applet.*;
import java.awt.*;
/*
<Applet code=”Ap3.class” width=”300″ height=”300″></applet>
*/
public class Ap3 extends Applet{
public void init(){
//setBackground(Color.red);
setBackground(new Color(100,255,0));
}
public void paint(Graphics g){
g.drawRect(50,50,100,200);
g.fillRect(100,100,50,50);
g.drawOval(150,150,200,200);
g.fillOval(200,100,150,50);
}
}
//:APPLET FACE OUTLINE CODE-3:
import java.applet.*;
import java.awt.*;
/*
<Applet code=”Ap4.class” width=”400″ height=”400″></applet>
*/
public class Ap4 extends Applet{
public void init(){
setBackground(Color.red);
setForeground(Color.yellow);
}
public void paint(Graphics g){
g.drawOval(20,20,350,350);
g.drawOval(90,120,40,40);
g.drawOval(240,120,40,40);
g.drawOval(170,150,40,140);
g.drawOval(130,310,140,40);
}
}
//:APPLET FILLED FACE CODE-4:
import java.applet.*;
import java.awt.*;
/*
<Applet code=”Ap5.class” width=”400″ height=”400″></applet>
*/
public class Ap5 extends Applet{
public void init(){
setBackground(Color.red);
setForeground(Color.yellow);
}
public void paint(Graphics g){
g.setColor(Color.white);
g.fillOval(20,20,350,350);
g.setColor(Color.black);
g.fillOval(90,120,40,40);
g.setColor(Color.blue);
g.fillOval(240,120,40,40);
g.setColor(Color.red);
g.fillOval(170,150,40,140);
g.setColor(Color.green);
g.fillOval(130,310,140,40);
}
}
Sep
09
class TestEx{
public static void main(String args[]){
try{
if(args.length==0){
String s=null;
System.out.println(s.length());
}
System.out.println(args[0].length());//3
int num1=Integer.parseInt(args[0]);
int num2=Integer.parseInt(args[1]);
System.out.println(num1/num2);
}
catch(NullPointerException e){
System.out.println(e);
}
catch(ArrayIndexOutOfBoundsException e){
System.out.println(e);
}
catch(ArithmeticException e){
System.out.println(e);
}
catch(NumberFormatException e){
System.out.println(e);
}
catch(Exception e){
System.out.println(e);
}
System.out.println(“exit from main”);
}
}