hjghjghjg
Thursday, July 23, 2015
Wednesday, July 8, 2015
ASP.NET HTML code
<body>
<form id="form1" runat="server">
<div>
<%--<h2>Spectacular Mountain</h2>--%>
<%-- <table width="100%" border="2"
style=" background-image: url('pic_mountain.jpg'); border-bottom-color: Aqua; height: 347px;">--%>
<table width="100%" border="2"
style=" border-bottom-color: Aqua; ">
<tr >
<td colspan="3" width="100%" style="background-color: Blue ">
<marquee> <asp:Label ID="Label1" runat="server" Text="WELCOME" ForeColor="DarkOrange" Font-Bold="true" Font-Size="X-Large" ></asp:Label> </marquee>
<img src="pic_mountain.jpg" width="100%" height="50%" alt="Mountain View"/>
</td>
</tr>
<tr>
<td width="20%" style="border:none">
<asp:HyperLink ID="HyperLink1" NavigateUrl="~/Home.aspx" runat="server"> HOME </asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink2" NavigateUrl="~/Home.aspx" runat="server"> HOME </asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink3" NavigateUrl="~/Home.aspx" runat="server"> HOME </asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink4" NavigateUrl="~/Home.aspx" runat="server"> HOME </asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink5" NavigateUrl="~/Home.aspx" runat="server"> HOME </asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink6" NavigateUrl="~/Home.aspx" runat="server"> HOME </asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink7" NavigateUrl="~/Home.aspx" runat="server"> HOME </asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink8" NavigateUrl="~/Home.aspx" runat="server"> HOME </asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink9" NavigateUrl="~/Home.aspx" runat="server"> HOME </asp:HyperLink>
<br />
</td>
<td width="40%" style="border:none;" valign="top" align="justify">
<h2 style="color:Olive " align="center">
LEARN TO FIX YOUR LOYALITY
</h2>
<p style="background-color:Orange; font-size:larger; color:Blue ">
Once there broke a war between the birds and the beasts. Many battles were fought one after the other. If vow the birds got the upper hand, the next time beasts were successful.
The bats played a very treacherous role in this war. They sided with whichever side got the better of the other. Thus they were changing their loyalty from side to side.
Neither side paid any attention to the bats till the war lasted. But when the war got over, the bats didn't know which side to go. First, they went to the birds. But the birds refused to own them as many birds had seen them fighting for the beasts.
Then, the bats went to the beasts. But there also they faced the same situation.
So, they were left all alone because of their disloyalty.
<br />
<font style=" font-size:x-large; background-color:Orange;"> The End.. </font>
<%-- <font style=" font-size:x-large; background-color:Orange;"> <center> The End.. </center> </font>--%>
</p>
</td>
<td width="40%" style="border:none">
<h2 style="color:Olive " align="center">
UNITED WE STAND ;DIVIDED WE FALL
</h2>
<p style="background-color:Olive; font-size:larger ">
Once upon a time three sons were engaged in merchantile business under the supervision of their father. They were very rich. Each son was proficient in his own department.
If one was good in sales, the other one was competent in purchases and similarly the third one in finance.
Unluckily, one day the father got bed ridden and the sons decided to divide the business under the fallacy that each of them were experts in their own way and can handle their individual business solely.
The father was glum and grumpy with their decision but was helpless and unfortunately the separation took place.
As a result three of them became each other's competitors. With the passage of time, they started having huge losses in their respective businesses. They tried all possible ways to succeed but the situation became worse.
Then they came to their father for a piece of advice. The father said "when you all were doing the business jointly, the business ran successfully. But it was not any one of you responsible for the success of the business rather traits of all three of you put together made the business successful".
The sons realized their mistake & got reunited. So we conclude that disunity always ruins.
The End..
</p>
</td>
</tr>
</table>
</div>
</form>
</body>
-----------------
Another Page
---------------
<body style="background-color:Green">
<form id="form1" runat="server">
<div>
<p style="font-size:xx-large; font-family:AngsanaUPC; color:Fuchsia; background-color:Olive">
<marquee> <% Response.Write("welcome to the Home page")%> </p> </marquee>
</div>
</form>
</body>
<form id="form1" runat="server">
<div>
<%--<h2>Spectacular Mountain</h2>--%>
<%-- <table width="100%" border="2"
style=" background-image: url('pic_mountain.jpg'); border-bottom-color: Aqua; height: 347px;">--%>
<table width="100%" border="2"
style=" border-bottom-color: Aqua; ">
<tr >
<td colspan="3" width="100%" style="background-color: Blue ">
<marquee> <asp:Label ID="Label1" runat="server" Text="WELCOME" ForeColor="DarkOrange" Font-Bold="true" Font-Size="X-Large" ></asp:Label> </marquee>
<img src="pic_mountain.jpg" width="100%" height="50%" alt="Mountain View"/>
</td>
</tr>
<tr>
<td width="20%" style="border:none">
<asp:HyperLink ID="HyperLink1" NavigateUrl="~/Home.aspx" runat="server"> HOME </asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink2" NavigateUrl="~/Home.aspx" runat="server"> HOME </asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink3" NavigateUrl="~/Home.aspx" runat="server"> HOME </asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink4" NavigateUrl="~/Home.aspx" runat="server"> HOME </asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink5" NavigateUrl="~/Home.aspx" runat="server"> HOME </asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink6" NavigateUrl="~/Home.aspx" runat="server"> HOME </asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink7" NavigateUrl="~/Home.aspx" runat="server"> HOME </asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink8" NavigateUrl="~/Home.aspx" runat="server"> HOME </asp:HyperLink>
<br />
<asp:HyperLink ID="HyperLink9" NavigateUrl="~/Home.aspx" runat="server"> HOME </asp:HyperLink>
<br />
</td>
<td width="40%" style="border:none;" valign="top" align="justify">
<h2 style="color:Olive " align="center">
LEARN TO FIX YOUR LOYALITY
</h2>
<p style="background-color:Orange; font-size:larger; color:Blue ">
Once there broke a war between the birds and the beasts. Many battles were fought one after the other. If vow the birds got the upper hand, the next time beasts were successful.
The bats played a very treacherous role in this war. They sided with whichever side got the better of the other. Thus they were changing their loyalty from side to side.
Neither side paid any attention to the bats till the war lasted. But when the war got over, the bats didn't know which side to go. First, they went to the birds. But the birds refused to own them as many birds had seen them fighting for the beasts.
Then, the bats went to the beasts. But there also they faced the same situation.
So, they were left all alone because of their disloyalty.
<br />
<font style=" font-size:x-large; background-color:Orange;"> The End.. </font>
<%-- <font style=" font-size:x-large; background-color:Orange;"> <center> The End.. </center> </font>--%>
</p>
</td>
<td width="40%" style="border:none">
<h2 style="color:Olive " align="center">
UNITED WE STAND ;DIVIDED WE FALL
</h2>
<p style="background-color:Olive; font-size:larger ">
Once upon a time three sons were engaged in merchantile business under the supervision of their father. They were very rich. Each son was proficient in his own department.
If one was good in sales, the other one was competent in purchases and similarly the third one in finance.
Unluckily, one day the father got bed ridden and the sons decided to divide the business under the fallacy that each of them were experts in their own way and can handle their individual business solely.
The father was glum and grumpy with their decision but was helpless and unfortunately the separation took place.
As a result three of them became each other's competitors. With the passage of time, they started having huge losses in their respective businesses. They tried all possible ways to succeed but the situation became worse.
Then they came to their father for a piece of advice. The father said "when you all were doing the business jointly, the business ran successfully. But it was not any one of you responsible for the success of the business rather traits of all three of you put together made the business successful".
The sons realized their mistake & got reunited. So we conclude that disunity always ruins.
The End..
</p>
</td>
</tr>
</table>
</div>
</form>
</body>
-----------------
Another Page
---------------
<body style="background-color:Green">
<form id="form1" runat="server">
<div>
<p style="font-size:xx-large; font-family:AngsanaUPC; color:Fuchsia; background-color:Olive">
<marquee> <% Response.Write("welcome to the Home page")%> </p> </marquee>
</div>
</form>
</body>
Tuesday, March 31, 2015
JAVA JDBC Code
//STEP 1. Import required packages import java.sql.*; public class JDBCExample { // JDBC driver name and database URL static final String JDBC_DRIVER = "com.mysql.jdbc.Driver"; static final String DB_URL = "jdbc:mysql://localhost/EMP"; // Database credentials static final String USER = "username"; static final String PASS = "password"; public static void main(String[] args) { Connection conn = null; Statement stmt = null; try{ //STEP 2: Register JDBC driver Class.forName("com.mysql.jdbc.Driver"); //STEP 3: Open a connection System.out.println("Connecting to database..."); conn = DriverManager.getConnection(DB_URL,USER,PASS); //STEP 4: Execute a query to create statment with // required arguments for RS example. System.out.println("Creating statement..."); stmt = conn.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); String sql; sql = "SELECT id, first, last, age FROM Employees"; ResultSet rs = stmt.executeQuery(sql); // Move cursor to the last row. System.out.println("Moving cursor to the last..."); rs.last(); //STEP 5: Extract data from result set System.out.println("Displaying record..."); //Retrieve by column name int id = rs.getInt("id"); int age = rs.getInt("age"); String first = rs.getString("first"); String last = rs.getString("last"); //Display values System.out.print("ID: " + id); System.out.print(", Age: " + age); System.out.print(", First: " + first); System.out.println(", Last: " + last); // Move cursor to the first row. System.out.println("Moving cursor to the first row..."); rs.first(); //STEP 6: Extract data from result set System.out.println("Displaying record..."); //Retrieve by column name id = rs.getInt("id"); age = rs.getInt("age"); first = rs.getString("first"); last = rs.getString("last"); //Display values System.out.print("ID: " + id); System.out.print(", Age: " + age); System.out.print(", First: " + first); System.out.println(", Last: " + last); // Move cursor to the first row. System.out.println("Moving cursor to the next row..."); rs.next(); //STEP 7: Extract data from result set System.out.println("Displaying record..."); id = rs.getInt("id"); age = rs.getInt("age"); first = rs.getString("first"); last = rs.getString("last"); //Display values System.out.print("ID: " + id); System.out.print(", Age: " + age); System.out.print(", First: " + first); System.out.println(", Last: " + last); //STEP 8: Clean-up environment rs.close(); stmt.close(); conn.close(); }catch(SQLException se){ //Handle errors for JDBC se.printStackTrace(); }catch(Exception e){ //Handle errors for Class.forName e.printStackTrace(); }finally{ //finally block used to close resources try{ if(stmt!=null) stmt.close(); }catch(SQLException se2){ }// nothing we can do try{ if(conn!=null) conn.close(); }catch(SQLException se){ se.printStackTrace(); }//end finally try }//end try System.out.println("Goodbye!"); }//end main }//end JDBCExample
Friday, March 13, 2015
JAVA JDBC
import java.sql.*;
import java.io.*;
class dataDB
{
DataInputStream in =new DataInputStream(System.in);
Connection con;
void connect()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:she","scott","tiger");
System.out.println("Connected");
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
void insert()throws IOException
{
Statement stmt;
try
{
stmt=con.createStatement();
System.out.println("How many records to insert?");
int n=Integer.parseInt(in.readLine());
for(int i=1;i<=n;i++)
{
System.out.println("Enter studid:");
int si=Integer.parseInt(in.readLine());
System.out.println("Enter stud name:");
String na=in.readLine();
System.out.println("Enter marks:");
int ma=Integer.parseInt(in.readLine());
String query="insert into studs values("+si+",'"+na+"',"+ma+")";
int rows=stmt.executeUpdate(query);
System.out.println("Rows Inserted");
con.commit();
}
}
catch(Exception e1)
{
System.out.println(e1+"Exception insertion");
}
}
void create()
{
Statement stmt;
try
{
stmt=con.createStatement();
String query="create table studs(studid number,name text,marks number)";
int rows=stmt.executeUpdate(query);
System.out.println("Table Created");
}
catch(SQLException e1)
{
System.out.println(e1.getMessage());
}
}
void update()throws IOException
{
Statement stmt;
try
{
stmt=con.createStatement();
System.out.println("Enter studid to update:");
int sid=Integer.parseInt(in.readLine());
System.out.println("Enter new marks:");
int ma=Integer.parseInt(in.readLine());
String query="update studs set marks="+ma+ " where studid="+sid;
int rows=stmt.executeUpdate(query);
System.out.println(rows+"Rows Updated");
con.commit();
}
catch(Exception e1)
{
System.out.println(e1.getMessage());
}
}
void delete()throws IOException
{
Statement stmt;
try
{
stmt=con.createStatement();
System.out.println("Enter studid:");
int si=Integer.parseInt(in.readLine());
String query="delete from studs where studid="+si;
int rows=stmt.executeUpdate(query);
System.out.println(rows+"Rows Deleted");
con.commit();
}
catch(Exception e1)
{
System.out.println(e1+"Exception Deletion");
}
}
void disp()throws IOException
{
Statement stmt;
try
{
stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from studs");
System.out.println("Student Details");
System.out.println("Studid Name Marks");
while(rs.next())
{
System.out.print(rs.getInt(1)+" ");
System.out.print(rs.getString(2)+" ");
System.out.print(rs.getString(3)+" \n ");
}
}
catch(Exception e1)
{
System.out.println(e1+"Exception insertion");
}
}
public static void main(String ar[])throws IOException
{
DataInputStream in =new DataInputStream(System.in);
dataDB d=new dataDB();
int c;
System.out.println("VARIOUS OPERATION ON DATABASE");
d.connect();
do
{
System.out.println("1.create");
System.out.println("2.insert");
System.out.println("3.delete");
System.out.println("4.modify");
System.out.println("5.display");
System.out.println(" enter ur choice:");
int ch=Integer.parseInt(in.readLine());
switch(ch)
{
case 1:
d.create();
break;
case 2:
d.insert();
break;
case 3:
d.delete();
break;
case 4:
d.update();
break;
case 5:
d.disp();
break;
}
System.out.println("Enter 1->Continue");
c=Integer.parseInt(in.readLine());
}while(c==1);
}
}
import java.io.*;
class dataDB
{
DataInputStream in =new DataInputStream(System.in);
Connection con;
void connect()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:she","scott","tiger");
System.out.println("Connected");
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
void insert()throws IOException
{
Statement stmt;
try
{
stmt=con.createStatement();
System.out.println("How many records to insert?");
int n=Integer.parseInt(in.readLine());
for(int i=1;i<=n;i++)
{
System.out.println("Enter studid:");
int si=Integer.parseInt(in.readLine());
System.out.println("Enter stud name:");
String na=in.readLine();
System.out.println("Enter marks:");
int ma=Integer.parseInt(in.readLine());
String query="insert into studs values("+si+",'"+na+"',"+ma+")";
int rows=stmt.executeUpdate(query);
System.out.println("Rows Inserted");
con.commit();
}
}
catch(Exception e1)
{
System.out.println(e1+"Exception insertion");
}
}
void create()
{
Statement stmt;
try
{
stmt=con.createStatement();
String query="create table studs(studid number,name text,marks number)";
int rows=stmt.executeUpdate(query);
System.out.println("Table Created");
}
catch(SQLException e1)
{
System.out.println(e1.getMessage());
}
}
void update()throws IOException
{
Statement stmt;
try
{
stmt=con.createStatement();
System.out.println("Enter studid to update:");
int sid=Integer.parseInt(in.readLine());
System.out.println("Enter new marks:");
int ma=Integer.parseInt(in.readLine());
String query="update studs set marks="+ma+ " where studid="+sid;
int rows=stmt.executeUpdate(query);
System.out.println(rows+"Rows Updated");
con.commit();
}
catch(Exception e1)
{
System.out.println(e1.getMessage());
}
}
void delete()throws IOException
{
Statement stmt;
try
{
stmt=con.createStatement();
System.out.println("Enter studid:");
int si=Integer.parseInt(in.readLine());
String query="delete from studs where studid="+si;
int rows=stmt.executeUpdate(query);
System.out.println(rows+"Rows Deleted");
con.commit();
}
catch(Exception e1)
{
System.out.println(e1+"Exception Deletion");
}
}
void disp()throws IOException
{
Statement stmt;
try
{
stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from studs");
System.out.println("Student Details");
System.out.println("Studid Name Marks");
while(rs.next())
{
System.out.print(rs.getInt(1)+" ");
System.out.print(rs.getString(2)+" ");
System.out.print(rs.getString(3)+" \n ");
}
}
catch(Exception e1)
{
System.out.println(e1+"Exception insertion");
}
}
public static void main(String ar[])throws IOException
{
DataInputStream in =new DataInputStream(System.in);
dataDB d=new dataDB();
int c;
System.out.println("VARIOUS OPERATION ON DATABASE");
d.connect();
do
{
System.out.println("1.create");
System.out.println("2.insert");
System.out.println("3.delete");
System.out.println("4.modify");
System.out.println("5.display");
System.out.println(" enter ur choice:");
int ch=Integer.parseInt(in.readLine());
switch(ch)
{
case 1:
d.create();
break;
case 2:
d.insert();
break;
case 3:
d.delete();
break;
case 4:
d.update();
break;
case 5:
d.disp();
break;
}
System.out.println("Enter 1->Continue");
c=Integer.parseInt(in.readLine());
}while(c==1);
}
}
Friday, March 6, 2015
Applet Frame
// Create a child frame window from within an applet.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="AppletFrame" width=400 height=600>
</applet>
*/
// Create a subclass of Frame.
class SampleFrame extends Frame {
SampleFrame(String title) {
super(title);
// create an object to handle window events
MyWindowAdapter adapter = new MyWindowAdapter(this);
// register it to receive those events
addWindowListener(adapter);
}
public void paint(Graphics g) {
g.drawString("This is in frame window", 10, 40);
}
}
class MyWindowAdapter extends WindowAdapter {
SampleFrame sampleFrame;
public MyWindowAdapter(SampleFrame sampleFrame) {
this.sampleFrame = sampleFrame;
}
public void windowClosing(WindowEvent we) {
sampleFrame.setVisible(false);
}
}
// Create frame window.
public class AppletFrame extends Applet implements ActionListener {
Button okButton;
TextField nameField;
Frame f;
public void init() {
f = new SampleFrame("A Frame Window");
okButton = new Button("Action!");
nameField = new TextField("Type here Something",35);
add(okButton);
okButton.addActionListener(this);
}
public void start() {
}
public void stop() {
f.setVisible(false);
}
public void actionPerformed(ActionEvent evt)
{
// Here we will ask what component called this method
if (evt.getSource() == okButton)
{
f.setSize(150, 150);
f.setVisible(true);
f.add(nameField);
nameField.setText("hello");
//nameField.setText("hello"));
}
}
public void paint(Graphics g) {
g.drawString("This is in applet window", 15, 30);
}
}
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="AppletFrame" width=400 height=600>
</applet>
*/
// Create a subclass of Frame.
class SampleFrame extends Frame {
SampleFrame(String title) {
super(title);
// create an object to handle window events
MyWindowAdapter adapter = new MyWindowAdapter(this);
// register it to receive those events
addWindowListener(adapter);
}
public void paint(Graphics g) {
g.drawString("This is in frame window", 10, 40);
}
}
class MyWindowAdapter extends WindowAdapter {
SampleFrame sampleFrame;
public MyWindowAdapter(SampleFrame sampleFrame) {
this.sampleFrame = sampleFrame;
}
public void windowClosing(WindowEvent we) {
sampleFrame.setVisible(false);
}
}
// Create frame window.
public class AppletFrame extends Applet implements ActionListener {
Button okButton;
TextField nameField;
Frame f;
public void init() {
f = new SampleFrame("A Frame Window");
okButton = new Button("Action!");
nameField = new TextField("Type here Something",35);
add(okButton);
okButton.addActionListener(this);
}
public void start() {
}
public void stop() {
f.setVisible(false);
}
public void actionPerformed(ActionEvent evt)
{
// Here we will ask what component called this method
if (evt.getSource() == okButton)
{
f.setSize(150, 150);
f.setVisible(true);
f.add(nameField);
nameField.setText("hello");
//nameField.setText("hello"));
}
}
public void paint(Graphics g) {
g.drawString("This is in applet window", 15, 30);
}
}
Tuesday, January 13, 2015
Tuesday, November 25, 2014
Find the IP address of the local machine
// Example 4.6
import java.net.*;
class MyAddress6 {
public static void main (String args[]) {
try {
InetAddress thisComputer = InetAddress.getLocalHost();
byte[] address = thisComputer.getAddress();
System.out.print("My address is ");
for (int i = 0; i < address.length; i++) {
int unsignedByte = address[i] < 0 ? address[i] + 256 : address[i];
System.out.print(unsignedByte + ".");
}
System.out.println();
}
catch (UnknownHostException e) {
System.out.println("I'm sorry. I don't know my own address.");
}
}
}
Subscribe to:
Posts (Atom)



