Posts

Write a SERVLET application to accept username and password, search them into database, if found then display appropriate message on the browser otherwise display error message.

UserPass.html <html> <body> <form method=post action="http://localhost:4141/Program/servlet/UserPass"> User Name :<input type=text name=user><br><br> Password :<input type=text name=pass><br><br> <input type=submit value="Login"> </form> </body> </html> UserPass.java import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; public class UserPass extends HttpServlet {     public void doGet(HttpServletRequest request, HttpServletResponse response)         throws IOException, ServletException     {             PrintWriter out = response.getWriter();             try{                         String us=reques...

Write a SERVLET program which counts how many times a user has visited a web page. If user is visiting the page for the first time, display a welcome message. If the user is revisiting the page, display the number of times visited. (Use Cookie)

import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class VisitServlet extends HttpServlet {     static int i=1;     public void doGet(HttpServletRequest request, HttpServletResponse response)         throws IOException, ServletException     {         response.setContentType("text/html");         PrintWriter out = response.getWriter();         String k=String.valueOf(i);         Cookie c = new Cookie("visit",k);         response.addCookie(c);         int j=Integer.parseInt(c.getValue());         if(j==1)         {             out.println("Welcome");  ...

Write a java program to create a student table with field’s rno, name and per. Insert values in the table. Display all the details of the student on screen. (Use PreparedStatement Interface)

import java.io.*; import java.sql.*; public class CreateStudentTable {           static Connection cn;             static Statement st;             static PreparedStatement ps;             static ResultSet rs;             public static void main(String args[])             {         try{                                     int rno,per;                     ...

Write a JDBC application using swing for the following:

Accept Query in TextField For 1. Create Table 2. Alter Table 3. Drop Table import java.io.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; class DDL extends JFrame implements ActionListener {             JLabel l1;             JButton b1,b2,b3;             JTextArea t1;             DDL()             {                         setLayout(null);                         l1=new JLabel("Type DDL Query");         ...

Write a JDBC program to delete the records of employees whose names are starting with ‘A’ character.

import java.sql.*; public class DeleteEmployeeRecord {           static Connection cn;             static Statement st;             public static void main(String args[])             {     try {                                     ResultSet rs,rs1;                                     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");              ...

Write a java program to create Teacher table(TNo.TName, Sal, Desg) and insert a record in it.

import java.io.*; import java.sql.*; public class CreateTeacherTable {            static Connection cn;             static Statement st;             public static void main(String args[])             {                    try                  {                                 int tno,sal;                         String tname,desg;                         BufferedReader br=new BufferedReader(new InputStreamReader(System.in));                         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");    ...

Write a JDBC program to remove “percentage” column from student (rno, sname, percentage) table

import java.io.*; import java.sql.*; public class RemoveColumn {           static Connection cn;             static Statement st;             static ResultSet rs;             public static void main(String args[])             {           try{                                     BufferedReader br=new BufferedReader(new InputStreamReader(System.in));                                     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");                                     cn=DriverManager.getConnection("jdbc:odbc:dsn","","");       ...