• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » Servlet » Servlet Database

Major Classes and Interfaces used to developing Java Application.

By Dinesh Thakur

Some of major classes and interfaces which are frequently used while developing a Java application are as follows:

• DriverManager class

• Driver interface

• Connection interface

• Statement interface

DriverManagerClass

It is a predefined class present/declared in java.sql package. It is a non-abstract class in the JDBC API. It has no constructor which implies that this class cannot be inherited or initialized directly.

All the methods or properties of this class are declared as static, so it is not necessary to construct an object of DriverManager Class. We can call these static methods using class name.

The main responsibility of the DriverManager class is preparing a connection by using Driver implementation that accepts the given JDBC URL.

Methods in DriverManager

(a) public static Connection getConnection (String url, String user name, String pswd);

Establishes connection between driver and database. This class selects a driver from the list of drivers and creates a connection by checking user parameter for which the connection is being made. Password parameter represents the password of the user.

(b) public static Driver getDriver (String url) throws SQLException

Locates the requested driver in the DriverManager class. The URL parameter specifies the URL of requested driver.

(c) public static void register (Driver drvr) throws SQLException:

Registers a requested driver with DriverManager Class.

(d) public static void deregister (Driver drvr) throws SQLException

Drops a driver from the list of the driver maintained by DriverManager.

Driver Interface

It is a predefined interface present in java.sql. package. It is a basic interface that every JDBC driver provider has to implement. The java.sql.Driver is an Interface defined under JDBCAPI to describe an object that is responsible to establish connection to database. All the driver classes implement this interface to connect to a database.

Methods in Driver Interface

(a) public Connection connect (String url, Properties info)

This method establishes connectivity with database. The URL parameter specifies a URL that describes the database details to which the driver is to be connected. The info parameter specifies the information of the tag/value pair used in driver.

Connection Interface

It is an interface present in java.sql package. This interface defines an abstraction to access the session, established with the database server. The JDBC connection helps to perform the following operation:

• Create JDBC Statement

• Control local transaction

Methods in Connection Interface

(a) public void close () throws SQLException

Closes the connection and releases the connection object associated with the connected database.

(b) public Statement createStatement () throws SQLException

Create a Statement object to send sql statements to the specified database.

(c) public PreparedStatement prepareStatement (String sql) throws SQLException

Create a PreparedStatement object to send sql statements over a connection.

(d) public CallableStatement prepareCall (String sql) throws SQLException

Create a CallableStatement object for calling database stored procedures.

(e) public void commit () throws SQLException

Commits the changes made in the previous commit and releases any database locks held by the current Connection object.

(f) public void rollback () throws SQLException

Rolls back all the transactions and releases any locks that are currently held by the Connection object.

Statement Interface

It is a predefined interface present in java.sql package. It is a part of JDBC API that abstracts an object. It is responsible to execute sql statement and return the result. A

Statement object can open a single ResultSet object at a time.

The PreparedStatement interface is dealing with IN parameter whereas the CallableStatement interface deals with both IN and OUT.

Methods of Statement Interface

(a) public int executeUpdate (String sql) throws SQLException

Execute the Insert, Update and Delete Statement or the SQL DDL statements.

(b) public ResultSet executeQuery (String sql) throws SQLException

Execute a sql command and return a single ResultSet.

(c) public void close () throws SQLException

Closes the Statement object, therefore, it releases its control from the database and also from the connection.

(d) public ResultSet getResultSet () throws SQLException

Retrieves the current Resultset object generated by Statement object.

(e) public Connection getConnection () throws SQLException

Accepts the Connection object made to the database.

ResultSet Interface

This interface provides methods for the retrieval of data returned by an SQL statement execution. A ResultSet maintains a cursor pointing to its current row of data. The most often used methods, namely, getXXX and updateXXX methods are present in this interface.

Methods in ResultSet

(a) public booleannext () throws SQLException

Moves the cursor down one row from its current position.

(b) public void close () throws SQLException

Releases this ResultSet object’s database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed.

(c) public booleanwasNull () throws SQLException

Reports whether the last column read had a value of SQL NULL.

(d) public StringgetXXX (int columnIndex) throws SQLException

Retrieves the value of the designated column in the current row of this ResultSet object as per the type of data.

(e) public void beforeFirst () throws SQLException

Moves the cursor to the front of this ResultSet object, just before the first row.

(f) public void afterLast () throws SQLException

Moves the cursor to the end of this ResultSet object, just after the last row.

(g) public booleanabsolute (int row) throws SQLException

Moves the cursor to the given row number in this ResultSet object.

(h) public booleanprevious () throws SQLException

Moves the cursor to the previous row in this ResultSet object.

(i) public void deleteRow () throws SQLException

Deletes the current row from this ResultSet object and from the underlying database.

(j) public void insertRow () throws SQLException

Inserts the contents of the insert row into this ResultSet object and into the database.

What is JDBC API? Important Goals of JDBC-API.

By Dinesh Thakur

The JDBC specification related API in the form of java.sql package.

In the JDBC API packages given in the next page can create methods of abstract, can create classes represent guidelines to develop JDBC drivers, whereas abstract methods of interface and abstract classes represent rules to develop JDBC drivers.

Each JDBC driver is set of classes implementing various interfaces of JDBC API packages. While defining methods of these interfaces the classes contain logic to interact with specific database software.

JDBC API provides a standard abstraction for Java application to access JOBC drivers, which is implemented by 3rd party vendor, i.e., database. In other words, JDBC API defines a standard protocol between a Java application and JDBC driver.

Important Goals of JDBC-API

• Provides a standard abstraction for submitting the SQL statements to access the data is database.

• Maintains focus on SQL.

• Support the compatibility with connectors.

• Provides a foundation for high-level API and keep it simple.

                   JDBC-API

MySql YEARWEEK Function in Java Servlet

By Dinesh Thakur

This function Will Returns the year and week.

We have create  database named ‘dbase’. After that a class is been declared named ‘MySqlYearWeekFunc’ extends the ‘HttpServlet’. With that kind of efforts, we need to define some methods, which do their job for exporting output. After we just declare Service method () (service method does the job of calling doGet() method for getting request).some variables also define as Connection,Resultset,PreparedStatement. Connection variable use to link between database and actual code (FrontEnd and BackEnd). preparedStatement will use to send the query to database like (Select YEARWEEK(CURDATE()) AS yrwk). This statement will work according to condition it shows. Now the next method executeQuery() will execute desired query and statement. And in the end doGet() method will be used to fetch the result on a web browser.

While getting the output on the web browser I use ‘HTML’ code and tag that will bring output in tabular form.

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlYearWeekFunc extends HttpServlet
   {
       public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
        {
            rp.setContentType("text/html");
            PrintWriter disp = rp.getWriter();
            String driver = "com.mysql.jdbc.Driver";
            String url = "jdbc:mysql://localhost/dbase";
            String uid = "root";
            String psw = "root";
            Connection con=null;
            PreparedStatement ps = null;
            ResultSet rs;
            try
             {
                 Class.forName(driver);
                 con = DriverManager.getConnection(url,uid,psw);
                 ps=con.prepareStatement("Select YEARWEEK(CURDATE()) AS yrwk");
                 rs = ps.executeQuery();
             String title = "Using Year Week Function";
                 String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
             disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                 "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
             "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>The Week Is</th>\n"+ "</body> </html>");
                 while(rs.next())
                     {
                          String curr = rs.getString(1);
                      disp.println("<tr><td align=\"center\">" + curr +"</td></tr>" );  
                      }     
             }        
                      catch(Exception e) 
                        {
                           e.printStackTrace();
                         }
                           disp.close();
        }
                        public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                 {
                                     doGet(rq,rp);
                                 }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlYearWeekFunc</servlet-name>
   <servlet-class>MySqlYearWeekFunc</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlYearWeekFunc</servlet-name>
   <url-pattern>/MySqlYearWeekFunc</url-pattern>
</servlet-mapping>

MySql Year Function in Java Servlet

By Dinesh Thakur

This Function will Returns the year.

i made a table in database named ‘dbase’ with required fields and within the reference of mySql(php myAdmin).then i import all the required java packages from java library. Then I made class, which extends ‘HttpServlet’ named ‘MySqlYearFunc’. I use here serviceMethod() that will use to getting the request from the doGet ()method. Before declaring desired variables, i loaded all the required drivers for database accessing. Then after, i declare variable like ‘connection’ that will make a link between the database and the actual code. Here i declare ‘resultSet’ Also which is been responsible for the fetching value from the columns and rows. I declare ‘preparedStatement’ that will use to executing selected query like executeQuery() as (Select YEAR(CURDATE()) AS yr).I use doGet()Method that will get Output on the web browser.

On the web Browser i use ‘Html’ tags to print the output in tabular form on the web browser this will present output in a Efficient look. 

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlYearFunc extends HttpServlet
   {
       public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
         {
             rp.setContentType("text/html");
             PrintWriter disp = rp.getWriter();
             String driver = "com.mysql.jdbc.Driver";
             String url = "jdbc:mysql://localhost/dbase";
             String uid = "root";
             String psw = "root";
             Connection con=null;
             PreparedStatement ps = null;
             ResultSet rs;
             try
              {
                  Class.forName(driver);
                  con = DriverManager.getConnection(url,uid,psw);
                  ps=con.prepareStatement("Select YEAR(CURDATE()) AS yr");
                  rs = ps.executeQuery();
              String title = "Using Year Function";
                  String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
             disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                 "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
             "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>The Year Is</th>\n"+ "</body> </html>");
                 while(rs.next())
                    {
                         String curr = rs.getString(1);
                     disp.println("<tr><td align=\"center\">" + curr +"</td></tr>" );  
                     }     
               }      
                     catch(Exception e) 
                        {
                               e.printStackTrace();
                        }
                               disp.close();
           }
                       public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                 {
                                     doGet(rq,rp);
                                 }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlYearFunc</servlet-name>
   <servlet-class>MySqlYearFunc</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlYearFunc</servlet-name>
   <url-pattern>/MySqlYearFunc</url-pattern>
</servlet-mapping>

MySql Where Clause in Java Servlet

By Dinesh Thakur

This function will show to the result according to Where Query in mysql.

Firstly, we need to make a table named ‘inq’ into a database named ‘dbase’. And after that we have to call the java Packages from java library. Now to define a class named ‘MySqlWhereClauseJavaServlet’ which is been, extend ‘HttpServlet’. And we need to be load the driver for database calling. To getting request we need to define serviceMethod().for whole procedure to produce output need to define some mandatory variables like connection (for making link between frontend and Backend).Resultset which represents the output table of data resulted from a SELECT query. preparedStatement the object of this statement will use to execute the query like executeQuery() it will return the object to resultset for produced output.preparedStatement will execute written query (SELECT emp_id, last_name,salary, manager_id FROM inq WHERE manager_id = 410″).At the last step we need to call the doGet() for getting request output on a web browser.

On to the web browser, we need to use ‘HTML’ code and its tags to get Output in Tabular form or in a manner Look.

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlWhereClauseJavaServlet extends HttpServlet
 {
     public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
        {
             rp.setContentType("text/html");
             PrintWriter disp = rp.getWriter();
             String driver = "com.mysql.jdbc.Driver";
             String url = "jdbc:mysql://localhost/dbase";
             String uid = "root";
             String psw = "root";
             Connection con=null;
             PreparedStatement ps = null;
             ResultSet rs;
             try
              {
                   Class.forName(driver);
                   con = DriverManager.getConnection(url,uid,psw);
                   ps=con.prepareStatement("SELECT emp_id, last_name,salary, manager_id FROM inq WHERE manager_id = 410");
                   rs = ps.executeQuery();
                String title = "Info With Where Clause";
                  String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
                disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                  "<body bgcolor=\"#f4efef\">\n" + "<h3 align=\"center\">" + title + "</h3>\n" + "<ul>\n" +
                "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Employee Id</th><th>Last Name</th><th>Salary</th><th>Manager Id</th>\n"+ "</body> </html>");
                  while(rs.next())
                      {
                             int e_id = rs.getInt("emp_id");
                        String l_name = rs.getString("last_name");
                        int sal = rs.getInt("salary");
                        int m_id = rs.getInt("manager_id");
                          disp.println("<tr><td align=\"center\">"+ e_id +"<td align=\"center\">"+ l_name +"<td align=\"center\">"+ sal +         "<td align=\"center\">"+ m_id +"</td></tr>" );           
                      }     
             }        
                          catch(Exception e) 
                              {
                                   e.printStackTrace();
                              }
                                   disp.close();
     }
                         public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                           {
                                     doGet(rq,rp);
                           }
 }
WEB.xml
 
<servlet>
   <servlet-name>MySqlWhereClauseJavaServlet</servlet-name>
   <servlet-class>MySqlWhereClauseJavaServlet</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlWhereClauseJavaServlet</servlet-name>
   <url-pattern>/MySqlWhereClauseJavaServlet</url-pattern>
</servlet-mapping>

MySql WEEKOFYEAR Function in Java Servlet

By Dinesh Thakur

This function Will Returns calendar week of the date (1-53).

First i made a table with required fields and values in that into a database named ‘dbase’ with the reference of mySql(php Myadmin). Then i import all the required packages from java library. Then i made a class named ‘MySqlWeekOfYearFunc’ extends the ‘HttpServlet’. Then i use serviceMethod() which will use to getting request from the doGet()Method for Output. Then load all the required Drivers. Then i declare some mandatory variables like connection (Connection variable is been used to make a bridge or link between database and actual code (java code)). As after creating link between both platforms, i declare resultSet, which will be use to fetch the values from required fields according to user. The other one variable is preparedStatement the object of this variable is ‘ps’ this will use to execute the query like executeQuery() as(Select WEEKOFYEAR(CURDATE()) AS week). To in the end i use doGet()Method for getting value on the web Browser.

While on the web browser to get output in tabular form i use ‘HTML’ code and tags for a Designer look.

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlWeekOfYearFunc extends HttpServlet
   {
       public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
        {
            rp.setContentType("text/html");
            PrintWriter disp = rp.getWriter();
            String driver = "com.mysql.jdbc.Driver";
            String url = "jdbc:mysql://localhost/dbase";
            String uid = "root";
            String psw = "root";
            Connection con=null;
            PreparedStatement ps = null;
            ResultSet rs;
            try
             {
                  Class.forName(driver);
                  con = DriverManager.getConnection(url,uid,psw);
                  ps=con.prepareStatement("Select WEEKOFYEAR(CURDATE()) AS week");
                  rs = ps.executeQuery();
              String title = "Using Week of Year Function";
                  String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
              disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                  "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
              "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>The Week Is</th>\n"+ "</body> </html>");
                  while(rs.next())
                     {
                            String curr = rs.getString(1);
                        disp.println("<tr><td align=\"center\">" + curr +"</td></tr>" );  
                      }     
             }        
                        catch(Exception e) 
                         {
                            e.printStackTrace();
                         }
                            disp.close();
         }
                         public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                 {
                                     doGet(rq,rp);
                                 }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlWeekOfYearFunc</servlet-name>
   <servlet-class>MySqlWeekOfYearFunc</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlWeekOfYearFunc</servlet-name>
   <url-pattern>/MySqlWeekOfYearFunc</url-pattern>
</servlet-mapping>

MySql WEEKDAY Function in Java Servlet

By Dinesh Thakur

This Function will return the weekday index.

i made a table in database named ‘dbase’ with required fields and within the reference of mySql(php myAdmin).Then i import all the required java packages from java library. Then i made class, which extends ‘HttpServlet’ named ‘MySqlWeekDayFunc’. I use here serviceMethod() that will use to getting the request from the doGet ()method. Before declaring desired variables, i load all the required drivers for database accessing. Then after, i declare variable like ‘connection’ that will make a link between the database and the actual code. Here i declare ‘resultSet’ Also that is been responsible for the fetching value from the columns and rows. I declare ‘preparedStatement’ that will use to executing selected query like executeQuery() as (Select WEEKDAY(‘2014-06-01’) AS wd)). I use doGet()Method that will get Output on the web browser.

To getting output on the web browser, I used ‘HTML’ code and tags that will bring output in tabular form that will make it a manner form.

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlWeekDayFunc extends HttpServlet
   {
       public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
        {
            rp.setContentType("text/html");
            PrintWriter disp = rp.getWriter();
            String driver = "com.mysql.jdbc.Driver";
            String url = "jdbc:mysql://localhost/dbase";
            String uid = "root";
            String psw = "root";
            Connection con=null;
            PreparedStatement ps = null;
            ResultSet rs;
            try
             {
                   Class.forName(driver);
                   con = DriverManager.getConnection(url,uid,psw);
                   ps=con.prepareStatement("Select WEEKDAY('2014-06-01') AS wd");
                   rs = ps.executeQuery();
               String title = "Using WEEKDAY Function";
                   String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
              disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                   "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
               "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>The Day is</th>\n"+ "</body> </html>");
                   while(rs.next())
                       {
                              String curr = rs.getString(1);
                          disp.println("<tr><td align=\"center\">" + curr +"</td></tr>" );  
                       }     
              }       
                           catch(Exception e) 
                              {
                              e.printStackTrace();
                          }
                              disp.close();
          }
                        public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                 {
                                     doGet(rq,rp);
                                 }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlWeekDayFunc</servlet-name>
   <servlet-class>MySqlWeekDayFunc</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlWeekDayFunc</servlet-name>
   <url-pattern>/MySqlWeekDayFunc</url-pattern>
</servlet-mapping>

MySql UTC_TIMESTAMP Function in Java Servlet

By Dinesh Thakur

This Function will Returns the current UTC date and time.

First i made a table in database named ‘dbase’ within the reference of mySql(php myAdmin). Then i import all the mandatory java packages from the java library as required for program. I made a class named ‘MySqlUTCTimeStampFunc’, which extends ‘HttpServlet’. I use serviceMethod() which is been carry the request from doGet()Method for Output. Then after, to declare the variable i loaded all the required drivers before for database accessing. Here i declare the variables like ‘connection’ this variable will create a link between database and java code. Then i call ‘resultSet’ this will be responsible for Getting value from the selected columns and the rows.

Then i declare ‘preparedStatement’ which will get to execute the selected query like executeQuery() as (Select UTC_TIMESTAMP() AS utc).Here i use doGet()Method which will use to get output on the web browser.

I use here ‘Html’ code and tags that will present the output in tabular form on the web browser.

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlUTCTimeStampFunc extends HttpServlet
   {
       public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
         {
              rp.setContentType("text/html");
              PrintWriter disp = rp.getWriter();
              String driver = "com.mysql.jdbc.Driver";
              String url = "jdbc:mysql://localhost/dbase";
              String uid = "root";
              String psw = "root";
              Connection con=null;
              PreparedStatement ps = null;
              ResultSet rs;
              try
               {
                   Class.forName(driver);
                   con = DriverManager.getConnection(url,uid,psw);
                   ps=con.prepareStatement("Select UTC_TIMESTAMP() AS utc");
                   rs = ps.executeQuery();
               String title = "Using UTC_TIMESTAMP Function";
                   String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
               disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                   "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
               "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Required Result Is</th>\n"+ "</body> </html>");
                   while(rs.next())
                        {
                              String curr = rs.getString(1);
                          disp.println("<tr><td align=\"center\">" + curr +"</td></tr>" );  
                         }     
               }      
                           catch(Exception e) 
                           {
                                e.printStackTrace();
                           }
                                disp.close();
       }
                       public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                   {
                                     doGet(rq,rp);
                                   }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlUTCTimeStampFunc</servlet-name>
   <servlet-class>MySqlUTCTimeStampFunc</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlUTCTimeStampFunc</servlet-name>
   <url-pattern>/MySqlUTCTimeStampFunc</url-pattern>
</servlet-mapping>

MySql UTC_TIME Function in Java Servlet

By Dinesh Thakur

This function will Returns the current UTC time.

I made a table in database named ‘dbase’ with required fields and within the reference of mySql(php myAdmin). Then i import all the required java packages from java library. Then i made class, which extends ‘HttpServlet’ named ‘MySqlUTCTimeFunc’. I use here serviceMethod() that will use to getting the request from the doGet ()method. Before declaring desired variables, i loaded all the required drivers for database accessing. Then after, i declare variable like ‘connection’ that will make a link between the database and the actual code. Here i declare ‘resultSet’ Also that is been responsible for the fetching value from the columns and rows. I declare ‘preparedStatement’ that will use to executing selected query like executeQuery() as (Select UTC_TIME() AS utc).I use doGet()Method that will get Output on the web browser.

To get output on the web browser in a tabular form i use ‘HTML’ code and tag which bring output In Impressive mode. 

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlUTCTimeFunc extends HttpServlet
   {
       public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
         {
             rp.setContentType("text/html");
             PrintWriter disp = rp.getWriter();
             String driver = "com.mysql.jdbc.Driver";
             String url = "jdbc:mysql://localhost/dbase";
             String uid = "root";
             String psw = "root";
             Connection con=null;
             PreparedStatement ps = null;
             ResultSet rs;
             try
               {
                     Class.forName(driver);
                     con = DriverManager.getConnection(url,uid,psw);
                     ps=con.prepareStatement("Select UTC_TIME() AS utc");
                     rs = ps.executeQuery();
                 String title = "Using UTC_TIME Function";
                     String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
                 disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                     "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
                 "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Required Result Is</th>\n"+ "</body> </html>");
                     while(rs.next())
                       {
                            String curr = rs.getString(1);
                        disp.println("<tr><td align=\"center\">" + curr +"</td></tr>" );  
                       }     
            }         
                        catch(Exception e) 
                            {
                           e.printStackTrace();
                            }
                           disp.close();
         }
                         public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                {
                                     doGet(rq,rp);
                                    }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlUTCTimeFunc</servlet-name>
   <servlet-class>MySqlUTCTimeFunc</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlUTCTimeFunc</servlet-name>
   <url-pattern>/MySqlUTCTimeFunc</url-pattern>
</servlet-mapping>

MySql UNIX_TIMESTAMP Function in Java Servlet

By Dinesh Thakur

This Function will Returns a UNIX timestamp.

First i made a database named ‘dbase’ within the reference of mySql(php myAdmin).Then after i import all java packages from java library as program need. Here i made a class named ‘MySqlUnixTimeStampFunc’,which extends ‘HttpServlet’. I use service()Method that will help to getting the request from doGet()Method for output on web browser. Then i loaded all the required Drivers that will help to accessing Database. After then, I declare variable first i use ‘connection’ variable that will create a link between database and the actual code(frontEnd and the backEnd).other variable is ‘ResultSet’ that will help to fetch value from the columns and rows as required query. The next variable is ‘preparedStatement’ that will use to executing the selected Query like executeQuery as (Select UNIX_TIMESTAMP(NOW()) AS uts).I use doGet()Method in last instance that will bring the output on web browser.

To Getting Output on web browser in a tabular form i use ‘HTML’ code and tags.

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlUnixTimeStampFunc extends HttpServlet
   {
       public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
         {
              rp.setContentType("text/html");
              PrintWriter disp = rp.getWriter();
              String driver = "com.mysql.jdbc.Driver";
              String url = "jdbc:mysql://localhost/dbase";
              String uid = "root";
              String psw = "root";
              Connection con=null;
              PreparedStatement ps = null;
              ResultSet rs;
              try
                {
                     Class.forName(driver);
                     con = DriverManager.getConnection(url,uid,psw);
                     ps=con.prepareStatement("Select UNIX_TIMESTAMP(NOW()) AS uts");
                     rs = ps.executeQuery();
                 String title = "Using UNIX_TIMESTAMP Function";
                     String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
                 disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                     "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
                 "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Required Result Is</th>\n"+ "</body> </html>");
                     while(rs.next())
                         {
                               String curr = rs.getString(1);
                           disp.println("<tr><td align=\"center\">" + curr +"</td></tr>" );  
                         }     
             }        
                           catch(Exception e) 
                          {
                                e.printStackTrace();
                          }
                                disp.close();
          }
                           public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                  {
                                     doGet(rq,rp);
                                  }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlUnixTimeStampFunc</servlet-name>
   <servlet-class>MySqlUnixTimeStampFunc</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlUnixTimeStampFunc</servlet-name>
   <url-pattern>/MySqlUnixTimeStampFunc</url-pattern>
</servlet-mapping>

MySql UNIXTIME () in Java Servlet

By Dinesh Thakur

This Function will Returns a UNIX time.

First i made a table in database named ‘dbase’ within the reference of mySql(php myAdmin). Then after, i import all the java packages from java library. I made a class named ‘MySqlUnixTime’, which extends ‘HttpServlet’. I use here the method service()Method that will use to getting the request from the doGet()Method for an output on the web browser. I loaded all the required drivers for accessing the database. I use here variables as required as i use ‘connection’ this variable will create a link between the database and the java code. This variable named ‘resultSet’ will use to get the value from the selected columns and rows from the selected table as required. After that i use to declare ‘preparedStatement’ that will use to executing the Selected query like executeQuery as (Select FROM_UNIXTIME(0) AS ut). I use doGet()Method for getting output on the web browser.

I Use ‘HTML’ code and some tags, which will show the output in tabular form on the web browser. 

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlUnixTime extends HttpServlet
   {
       public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
         {
             rp.setContentType("text/html");
             PrintWriter disp = rp.getWriter();
             String driver = "com.mysql.jdbc.Driver";
             String url = "jdbc:mysql://localhost/dbase";
             String uid = "root";
             String psw = "root";
             Connection con=null;
             PreparedStatement ps = null;
             ResultSet rs;
             try
               {
                     Class.forName(driver);
                     con = DriverManager.getConnection(url,uid,psw);
                     ps=con.prepareStatement("Select FROM_UNIXTIME(0) AS ut");
                     rs = ps.executeQuery();
                 String title = "Using From_UNIXTIME Function";
                     String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
                 disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                     "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
                 "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Required Result</th>\n"+ "</body> </html>");
                     while(rs.next())
                         {
                               String curr = rs.getString(1);
                           disp.println("<tr><td align=\"center\">" + curr +"</td></tr>" );  
                         }     
               }      
                           catch(Exception e) 
                           {
                              e.printStackTrace();
                           }
                              disp.close();
          }
                        public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                  {
                                     doGet(rq,rp);
                                  }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlUnixTime</servlet-name>
   <servlet-class>MySqlUnixTime</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlUnixTime</servlet-name>
   <url-pattern>/MySqlUnixTime</url-pattern>
</servlet-mapping>

MySql UNHEX Function in Java Servlet

By Dinesh Thakur

This Function will convert each pair of hexadecimal digits to a character.

Here i made a database named ‘dbase’ within the reference of mySql(php myAdmin). First, i import all the required java packages from java library. Then after, i made a class named ‘MySqlUNHEXFunction’ extends the ‘HttpServlet’. I use the serviceMethod() which is responsible for the getting request from doGet() method. Then after, need to load all the drivers as required. And to declare the mandatory variables like Connection (the variable Connection will use to establish the link between database and java code (actual code). ResultSet the variable resultset does the job to fetch the value from required columns and rows. preparedStatement this variable use to execute the query like executeQuery() as (Select UNHEX(‘4D7953514C’)) And after then i use doGet() method to get the output on the web Browser.

On the web Browser, i use ‘HTML’ tags that will represent the output in tabular form.

import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlUNHEXFunction extends HttpServlet
   {
       public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
         {
             rp.setContentType("text/html");
             PrintWriter disp = rp.getWriter();
             String driver = "com.mysql.jdbc.Driver";
             String url = "jdbc:mysql://localhost/dbase";
             String uid = "root";
             String psw = "root";
             Connection con=null;
             PreparedStatement ps = null;
             ResultSet rs;
             try
               {
                    Class.forName(driver);
                    con = DriverManager.getConnection(url,uid,psw);
                    ps=con.prepareStatement("Select UNHEX('4D7953514C')");
                    rs = ps.executeQuery();
                String title = "Using UNHEX Function";
                    String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
                disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                    "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
                "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Value Is </th>\n"+ "</body> </html>");
                   while(rs.next())
                        {
                              String val = rs.getString(1);
                          disp.println("<tr><td align=\"center\">" + val +"</td></tr>" );  
                        }     
              }       
                           catch(Exception e) 
                           {
                                e.printStackTrace();
                           }
                                disp.close();
         }
                         public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                 {
                                     doGet(rq,rp);
                                 }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlUNHEXFunction</servlet-name>
   <servlet-class>MySqlUNHEXFunction</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlUNHEXFunction</servlet-name>
   <url-pattern>/MySqlUNHEXFunction</url-pattern>
</servlet-mapping>

MySql UCASE Function in Java Servlet

By Dinesh Thakur

This Function is Synonym for UPPER () Case.

I use to made a database first named ‘dbase’ within the reference of mySql(php myAdmin). Then i import all important java packages from java library. Then i made a class named ‘MySqlUCASEFunction’ extends ‘HttpServlet’. Then i use service()Method this will be responsible for the getting the request from the doGet()Method for output. Then i loaded all the required drivers for the database accessing. Then i use to set variables like i use first variable ‘connection’ that will be responsible for the creating a link between database and the java code. Then i use ‘resultSet’ this will use to get value from the selected columns and the rows from table. i use here ‘preparedStatement’ that use to executing the selected query like executeQuery() as (Select UCASE(‘mysql’) AS ucs). Then in last phase i use doGet()Method that will provide the output on the web browser.

To Getting Output on web browser in a tabular form i use ‘HTML’ code and tags.

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlUCASEFunction extends HttpServlet
   {
       public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
        {
            rp.setContentType("text/html");
            PrintWriter disp = rp.getWriter();
            String driver = "com.mysql.jdbc.Driver";
            String url = "jdbc:mysql://localhost/dbase";
            String uid = "root";
            String psw = "root";
            Connection con=null;
            PreparedStatement ps = null;
            ResultSet rs;
            try
            {
                 Class.forName(driver);
                 con = DriverManager.getConnection(url,uid,psw);
                 ps=con.prepareStatement("Select UCASE('mysql') AS ucs");
                 rs = ps.executeQuery();
             String title = "Using UCASE Function";
                 String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
             disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                 "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
             "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Value Is </th>\n"+ "</body> </html>");
                 while(rs.next())
                    {
                         String val = rs.getString(1);
                     disp.println("<tr><td align=\"center\">" + val +"</td></tr>" );  
                    }     
             }        
                     catch(Exception e) 
                        {
                         e.printStackTrace();
                        }
                         disp.close();
        }
                       public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                 {
                                     doGet(rq,rp);
                                 }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlUCASEFunction</servlet-name>
   <servlet-class>MySqlUCASEFunction</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlUCASEFunction</servlet-name>
   <url-pattern>/MySqlUCASEFunction</url-pattern>
</servlet-mapping>

MySql TRUNCATE Function in Java Servlet

By Dinesh Thakur

This Function Returns numeric exp 1 truncated to exp 2 decimal places.

First i made a database named ‘dbase’ within the complete reference of mySql(php myAdmin). Then i import all the required java package from java library as program need. Then after i made a class named ‘MySqlTRUNCATEFunction’ that is been extends the ‘HttpServlet’. Then i use to get request from doGet()method the serviceMethod() for output on web browser. Then i loaded all the mandatory drivers for database accessing. After then the next move is to declare variables like i use ‘connection’ this will use to make a bridge or link between database and the actual code(java code).After then i use ‘resultSet’ that will be responsible for the getting value from the selected columns and rows. Then i use ‘preparedStatement’ this will use to executing the selected query like executeQuery as (Select TRUNCATE(4.678,1)). In the last i use doGet() method that will bring the output on the web browser.

To get Output in a manner form i use ‘Html’ tags, which will appear Output in a tabular form on the web browser.

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlTRUNCATEFunction extends HttpServlet
   {
       public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
          {
              rp.setContentType("text/html");
              PrintWriter disp = rp.getWriter();
              String driver = "com.mysql.jdbc.Driver";
              String url = "jdbc:mysql://localhost/dbase";
              String uid = "root";
              String psw = "root";
              Connection con=null;
              PreparedStatement ps = null;
              ResultSet rs;
              try
                {
                      Class.forName(driver);
                      con = DriverManager.getConnection(url,uid,psw);
                      ps=con.prepareStatement("Select TRUNCATE(4.678,1)");
                      rs = ps.executeQuery();
                  String title = "Using TRUNCATE Function";
                      String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
                  disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                      "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
                  "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Value</th>\n"+ "</body> </html>");
                      while(rs.next())
                        {
                               String val = rs.getString(1);
                           disp.println("<tr><td align=\"center\">" + val +"</td></tr>" );  
                        }     
             }        
                           catch(Exception e) 
                              {
                                   e.printStackTrace();
                              }
                                   disp.close();
           }
                        public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                   {
                                     doGet(rq,rp);
                                   }
   }
WEB.xml
<servlet>
   <servlet-name>MySqlTRUNCATEFunction</servlet-name>
   <servlet-class>MySqlTRUNCATEFunction</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlTRUNCATEFunction</servlet-name>
   <url-pattern>/MySqlTRUNCATEFunction</url-pattern>
</servlet-mapping>

MySql TRIM Function in Java Servlet

By Dinesh Thakur

This function will remove leading and trailing spaces.

First i made a database named ‘dbase’ within the reference of mySql(php myAdmin). Then after I import all java packages from java library as program need. Here i made a class named ‘MySqlTRIMFunction’, which extends ‘HttpServlet’. I use service()Method that will help to getting the request from doGet()Method for output on web browser. Then i loaded all the required Drivers that will help to accessing Database. After, then i declare variable first i use ‘connection’ variable that will create a link between database and the actual code (frontend and the backend). Other variable is ‘ResultSet’ that will help to fetch value from the columns and rows as required query. The next variable is ‘preparedStatement’ that will use to executing the selected Query like executeQuery as (Select TRIM(‘  mysql  ‘). I use doGet()Method in last instance that will bring the output on web browser.

While getting the output on the web browser i use ‘HTML’ code and tags that present output in tabular form.

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlTRIMFunction extends HttpServlet
   {
       public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
         {
              rp.setContentType("text/html");
              PrintWriter disp = rp.getWriter();
              String driver = "com.mysql.jdbc.Driver";
              String url = "jdbc:mysql://localhost/dbase";
              String uid = "root";
              String psw = "root";
              Connection con=null;
              PreparedStatement ps = null;
              ResultSet rs;
              try
               {
                     Class.forName(driver);
                     con = DriverManager.getConnection(url,uid,psw);
                     ps=con.prepareStatement("Select TRIM('  mysql  ')");
                     rs = ps.executeQuery();
                 String title = "Using TRIM Function";
                     String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
                 disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                     "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
                 "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Value Is </th>\n"+ "</body> </html>");
                     while(rs.next())
                          {
                                 String val = rs.getString(1);
                             disp.println("<tr><td align=\"center\">" + val +"</td></tr>" );  
                          }     
               }      
                            catch(Exception e) 
                              {
                                    e.printStackTrace();
                              }
                                    disp.close();
         }
                        public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                  {
                                     doGet(rq,rp);
                                  }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlTRIMFunction</servlet-name>
   <servlet-class>MySqlTRIMFunction</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlTRIMFunction</servlet-name>
   <url-pattern>/MySqlTRIMFunction</url-pattern>
</servlet-mapping>

MySql TO_DAYS Function in Java Servlet

By Dinesh Thakur

This Function Will Returns the date argument converted to days.

First i made a database named ‘dbase’ within the reference of mySql(php myAdmin). Then i import all the required java packages from java library as program essentials. I made a class named ‘MySqlToDaysFunc’, which extends ‘HttpServlet’. Then i use service()Method which will use to get the request from the doGet()Method for output on the browser. I loaded all the required drivers for accessing database as required. Then i use to declare the variable as i use ‘connection’ this will use to create a link between the database and the java code. Then i declare ‘resultSet’ this will responsible for get the value from selected columns and the rows. i use here now ‘preparedStatement’ this will execute the selected Query like executeQuery as (SELECT TO_DAYS(‘2014-05-31’) AS todys). Then i use doGet()Method that will bring the output on the web browser.

On the other hand, i use ‘HTML’ code and tags for presenting the output in a tabular form or in a manner way on the web browser.

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlToDaysFunc extends HttpServlet
   {
       public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
        {
            rp.setContentType("text/html");
            PrintWriter disp = rp.getWriter();
            String driver = "com.mysql.jdbc.Driver";
            String url = "jdbc:mysql://localhost/dbase";
            String uid = "root";
            String psw = "root";
            Connection con=null;
            PreparedStatement ps = null;
            ResultSet rs;
            try
             {
                 Class.forName(driver);
                 con = DriverManager.getConnection(url,uid,psw);
                 ps=con.prepareStatement("SELECT TO_DAYS('2014-05-31') AS todys");
                 rs = ps.executeQuery();
             String title = "Using To_Days Function";
                 String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
             disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                 "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
             "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Result</th>\n"+ "</body> </html>");
                 while(rs.next())
                    {
                         String curr = rs.getString(1);
                     disp.println("<tr><td align=\"center\">" + curr +"</td></tr>" );  
                    }     
             }        
                     catch(Exception e) 
                        {
                          e.printStackTrace();
                        }
                          disp.close();
         }
                         public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                  {
                                     doGet(rq,rp);
                                  }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlToDaysFunc</servlet-name>
   <servlet-class>MySqlToDaysFunc</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlToDaysFunc</servlet-name>
   <url-pattern>/MySqlToDaysFunc</url-pattern>
</servlet-mapping>

MySql TIME_TO_SEC Function in Java Servlet

By Dinesh Thakur

This Function will Returns the argument converted to seconds.

First i made a table in database named ‘dbase’ within the reference of mySql(php myAdmin). Then i import all the required java package from java library. I make a class named ‘MySqlTimeToSecondFunc’ extends the ‘HttpServlet’.i use here serviceMethod() which is use to getting request from the doGet()Method for output. Before activating all the variable i loaded all the required drivers for the database accessing then after i declare variables like first i declare ‘connection'(this variable will act as to create a link between database and the actual code. Here i declare second one is ‘resultSet’ this will take the responsible for fetching the value from columns and the selected rows. Here i declare one more ‘preparedStatement’ this will use to executing the selected query like executeQuery() as (SELECT TIME_TO_SEC(’01:00′) AS tmtosec)).I use doGet()Method which will bring the output on the web browser.

To get the Output in an impressive look i use some tags of ‘HTML’ Code, which will bring the Output in tabular form on a web browser.

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlTimeToSecondFunc extends HttpServlet
   {
       public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
         {
             rp.setContentType("text/html");
             PrintWriter disp = rp.getWriter();
             String driver = "com.mysql.jdbc.Driver";
             String url = "jdbc:mysql://localhost/dbase";
             String uid = "root";
             String psw = "root";
             Connection con=null;
             PreparedStatement ps = null;
             ResultSet rs;
             try
              {
                   Class.forName(driver);
                   con = DriverManager.getConnection(url,uid,psw);
                   ps=con.prepareStatement("SELECT TIME_TO_SEC('01:00') AS tmtosec");
                   rs = ps.executeQuery();
               String title = "Using Time To Second Function";
                   String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
              disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                  "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
              "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Result</th>\n"+ "</body> </html>");
                  while(rs.next())
                      {
                           String curr = rs.getString(1);
                       disp.println("<tr><td align=\"center\">" + curr +"</td></tr>" );  
                      }     
             }        
                       catch(Exception e) 
                          {
                          e.printStackTrace();
                          }
                          disp.close();
         }
                         public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                 {
                                     doGet(rq,rp);
                                 }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlTimeToSecondFunc</servlet-name>
   <servlet-class>MySqlTimeToSecondFunc</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlTimeToSecondFunc</servlet-name>
   <url-pattern>/MySqlTimeToSecondFunc</url-pattern>
</servlet-mapping>

MySql TimeStamp Function in Java Servlet

By Dinesh Thakur

This function returns the date or date time expression.

First i make a table in database named ‘dbase’ with required fields and values in it and within the reference of mySql(Php Admin).then i import all the required java package from java library. I made a class named ‘MySqlTimeStampFunc’ extends the ‘HttpServlet’. Then i use serviceMethod() which will bring the request from doGet()Method for Output. Then i load all the drivers for database accessing. After, then i declare variables, which are necessary for database conditions as i declare connection (this variable will use to make a link between database and java code or actual code). After, then i declare resultset (this variable will use to get the values from desired columns and rows as required from query).The next one will be the preparedStatement (this variable will responsible for the executing query like executeQuery() as (SELECT TIMESTAMP(‘2014-05-31 22:11:11’) AS ts). In the last i used the doGet()Method which will bring the output on the web Browser.

I use here some tags of ‘HTML’ that will bring output in a tabular form as required.  

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlTimeStampFunc extends HttpServlet
   {
      public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
       {
            rp.setContentType("text/html");
            PrintWriter disp = rp.getWriter();
            String driver = "com.mysql.jdbc.Driver";
            String url = "jdbc:mysql://localhost/dbase";
            String uid = "root";
            String psw = "root";
            Connection con=null;
            PreparedStatement ps = null;
            ResultSet rs;
            try
             {
                  Class.forName(driver);
                  con = DriverManager.getConnection(url,uid,psw);
                  ps=con.prepareStatement("SELECT TIMESTAMP('2014-05-31 22:11:11') AS ts");
                  rs = ps.executeQuery();
              String title = "Using Time Stamp Function";
                  String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
             disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                  "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
              "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Result</th>\n"+ "</body> </html>");
                 while(rs.next())
                     {
                          String curr = rs.getString(1);
                      disp.println("<tr><td align=\"center\">" + curr +"</td></tr>" );   
                     }     
             }        
                      catch(Exception e) 
                           {
                           e.printStackTrace();
                        }
                           disp.close();
        }
                       public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                 {
                                     doGet(rq,rp);
                                 }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlTimeStampFunc</servlet-name>
   <servlet-class>MySqlTimeStampFunc</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlTimeStampFunc</servlet-name>
   <url-pattern>/MySqlTimeStampFunc</url-pattern>
</servlet-mapping>

MySql TIMESTAMPDIFF Function in Java Servlet

By Dinesh Thakur

This function will Subtracts an interval from a date time expression.

First i make a table in database named ‘dbase’ within the reference of mySql(php myAdmin).Then i import all the required java packages from the java library. Then i made a class named ‘MySqlTimeStampDiffFunc’, which extends ‘HttpServlet’. Then after i use service()Mehod which will get the request from the doGet()Method. Then i load all the require drivers for the database accessing. Here I declare the variables like ‘connection’ this variable will take over to create a link between a database and the java code. The other i declare ‘resultSet’ this will use to fetch the value from the columns and the rows from selected table. Then i declare the ‘preparedStatement’ this variable will execute the selected query like executeQuery() as (SELECT TIMESTAMPDIFF(MONTH,’2014-05-31′,’2014-07-20′) AS tsdiff).I here use doGet()Method that will bring the output on the web browser.

On the web Browser I use ‘Html’ tags to print the output in tabular form on the web browser this will present output in a manner way.

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlTimeStampDiffFunc extends HttpServlet
   {
       public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
         {
             rp.setContentType("text/html");
             PrintWriter disp = rp.getWriter();
             String driver = "com.mysql.jdbc.Driver";
             String url = "jdbc:mysql://localhost/dbase";
             String uid = "root";
             String psw = "root";
             Connection con=null;
             PreparedStatement ps = null;
             ResultSet rs;
             try
              {
                   Class.forName(driver);
                   con = DriverManager.getConnection(url,uid,psw);
                   ps=con.prepareStatement("SELECT TIMESTAMPDIFF(MONTH,'2014-05-31','2014-07-20') AS tsdiff");
                   rs = ps.executeQuery();
               String title = "Using Time Stamp Difference Function";
                   String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
               disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                   "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
               "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Result</th>\n"+ "</body> </html>");
                   while(rs.next())
                        {
                              String curr = rs.getString(1);
                          disp.println("<tr><td align=\"center\">" + curr +"</td></tr>" );  
                        }     
               }      
                          catch(Exception e) 
                          {
                               e.printStackTrace();
                          }
                               disp.close();
        }
                           public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                  {
                                     doGet(rq,rp);
                                  }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlTimeStampDiffFunc</servlet-name>
   <servlet-class>MySqlTimeStampDiffFunc</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlTimeStampDiffFunc</servlet-name>
   <url-pattern>/MySqlTimeStampDiffFunc</url-pattern>
</servlet-mapping>

MySql TimeStampAdd Function in Java Servlet

By Dinesh Thakur

This Function adds an interval to a date time expression.

i made a table in database named ‘dbase’ with required fields and within the reference of mySql(php myAdmin). Then i import all the required java packages from java library. Then i made class, which extends ‘HttpServlet’ named ‘MySqlTimeStampAddFunc’. I use here serviceMethod() that will use to getting the request from the doGet()method. Before declaring desired variables, i loaded all the required drivers for database accessing. Then after, i declare variable like ‘connection’ that will make a link between the database and the actual code. Here i declare ‘resultSet’ Also that is been responsible for the fetching value from the columns and rows. I declare ‘preparedStatement’ that will use to executing selected query like executeQuery() as (SELECT TIMESTAMPADD(HOUR,2,’22:11:11′) AS tsadd).I use doGet()Method that will get Output on the web browser.

To feel look good the result we use a tabular form concept. For this kind of requirement, we use ‘HTML’ coding and some of tags to use Output in Designer look to show on a web browser. 

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlTimeStampAddFunc extends HttpServlet
   {
       public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
          {
              rp.setContentType("text/html");
              PrintWriter disp = rp.getWriter();
              String driver = "com.mysql.jdbc.Driver";
              String url = "jdbc:mysql://localhost/dbase";
              String uid = "root";
              String psw = "root";
              Connection con=null;
              PreparedStatement ps = null;
              ResultSet rs;
              try
               {
                    Class.forName(driver);
                    con = DriverManager.getConnection(url,uid,psw);
                    ps=con.prepareStatement("SELECT TIMESTAMPADD(HOUR,2,'22:11:11') AS tsadd");
                    rs = ps.executeQuery();
                String title = "Using Time Stamp Add Function";
                    String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
                disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                    "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
                "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Result</th>\n"+ "</body> </html>");
                    while(rs.next())
                        {
                             String curr = rs.getString(1);
                         disp.println("<tr><td align=\"center\">" + curr +"</td></tr>" );  
                        }     
              }       
                         catch(Exception e) 
                         {
                            e.printStackTrace();
                         }
                            disp.close();
          }
                           public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                  {
                                     doGet(rq,rp);
                                  }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlTimeStampAddFunc</servlet-name>
   <servlet-class>MySqlTimeStampAddFunc</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlTimeStampAddFunc</servlet-name>
   <url-pattern>/MySqlTimeStampAddFunc</url-pattern>
</servlet-mapping>

MySqlTime Function in Java Servlet

By Dinesh Thakur

The function ‘TIME’ will show the current TIME of System.

I made a table in database named ‘dbase’ with required fields and within the reference of mySql(php myAdmin). Then i import all the required java packages from java library. Then i made class, which extends ‘HttpServlet’ named ‘MySqlTimeFunc’. I use here serviceMethod() that will use to getting the request from the doGet ()method. Before declaring desired variables, i load all the required drivers for database accessing. Then after, i declare variable like ‘connection’ that will make a link between the database and the actual code. Here i declare ‘resultSet’ Also that is been responsible for the fetching value from the columns and rows. I declare ‘preparedStatement’ that will use to executing selected query like executeQuery() as (Select TIME(now()) AS tm).I use doGet()Method that will get Output on the web browser.

While getting the output on the web browser i use ‘HTML’ code and tags that present output in tabular form.

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlTimeFunc extends HttpServlet
   {
      public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
        {
            rp.setContentType("text/html");
            PrintWriter disp = rp.getWriter();
            String driver = "com.mysql.jdbc.Driver";
            String url = "jdbc:mysql://localhost/dbase";
            String uid = "root";
            String psw = "root";
            Connection con=null;
            PreparedStatement ps = null;
            ResultSet rs;
            try
              {
                  Class.forName(driver);
                  con = DriverManager.getConnection(url,uid,psw);
                  ps=con.prepareStatement("Select TIME(now()) AS tm");
                  rs = ps.executeQuery();
              String title = "Using Time Function";
                  String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
             disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                 "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
             "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Result</th>\n"+ "</body> </html>");
                 while(rs.next())
                      {
                            String curr = rs.getString(1);
                        disp.println("<tr><td align=\"center\">" + curr +"</td></tr>" );  
                      }     
             }        
                        catch(Exception e) 
                         {
                            e.printStackTrace();
                         }
                            disp.close();
         }
                         public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                  {
                                     doGet(rq,rp);
                                  }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlTimeFunc</servlet-name>
   <servlet-class>MySqlTimeFunc</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlTimeFunc</servlet-name>
   <url-pattern>/MySqlTimeFunc</url-pattern>
</servlet-mapping>

MySql TIMEDIFF Function in Java Servlet

By Dinesh Thakur

This Function is use to check the difference of Time or subtracts the time.

First i make a table in database named ‘dbase’ with required fields and values which is under the reference of mySql(php myAdmin).Here i import all mandatory java package from the java library as program needs. Then after, i make a class named ‘MySqlTimeDiffFunc’ extends ‘HttpServlet’. And here i use serviceMethod() which will get request from the doGet()Method for getting output on the web browser. After, i load all the required drivers for accessing database. After then i declare mandatory variables as i declare ‘Connection’ this variable does the job to create a link between database and the actual code. The other one i declare is ‘resultSet’ that will fetch the value from selected column and rows. Now here i declare the ‘preparedStatement’ that will use to execute the selected query like executeQuery() as (SELECT TIMEDIFF(‘2014-05-31 15:45:57′,’2014-05-31 13:40:50’) AS td).Here i use the doGet()Method for output on a web browser.

To get output in tabular form on the web browser i use ‘HTML’ code and some tags.

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlTimeDiffFunc extends HttpServlet
   {
      public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
        {
            rp.setContentType("text/html");
            PrintWriter disp = rp.getWriter();
            String driver = "com.mysql.jdbc.Driver";
            String url = "jdbc:mysql://localhost/dbase";
            String uid = "root";
            String psw = "root";
            Connection con=null;
            PreparedStatement ps = null;
            ResultSet rs;
            try
              {
                   Class.forName(driver);
                   con = DriverManager.getConnection(url,uid,psw);
                   ps=con.prepareStatement("SELECT TIMEDIFF('2014-05-31 15:45:57','2014-05-31 13:40:50') AS td");
                   rs = ps.executeQuery();
               String title = "Using Time Difference Function";
                   String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
              disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                  "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
              "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Result</th>\n"+ "</body> </html>");
                 while(rs.next())
                   {
                         String curr = rs.getString(1);
                     disp.println("<tr><td align=\"center\">" + curr +"</td></tr>" );  
                   }     
             }        
                     catch(Exception e) 
                            {
                         e.printStackTrace();
                        }
                         disp.close();
         }
                       public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                  {
                                     doGet(rq,rp);
                                  }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlTimeDiffFunc</servlet-name>
   <servlet-class>MySqlTimeDiffFunc</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlTimeDiffFunc</servlet-name>
   <url-pattern>/MySqlTimeDiffFunc</url-pattern>
</servlet-mapping>

MySql TAN Function in Java Servlet

By Dinesh Thakur

This function will Returns the tangent of numeric expression expressed in radians.

I make a table in database named ‘dbase’ which is been created in the reference of mySql(php myAdmin). Then i import all the required java packages from java library as required from program need. Then, i make a class named ‘MySqlTANFunction’ extends ‘HttpServlet’. After that i use serviceMethod()that will get request from doGet()method for output on the web browser. Before declaring the variables as required, i loaded all the mandatory drivers for database accessing. Here i declare ‘Connection’ this variable will be the responsible for the making bridge or path between the database and the java code. The other one will be the ‘resultSet’ this one will help to fetch the values from the selected columns and the rows. Here i declare ‘preparedStatement’ this will bring execute the selected query like executeQuery() as (Select TAN(1)).Here i use doGet()Method that will bring the output on the web browser.

To make output Impressive I use ‘HTML’ tags to get Output in tabular form on a web browser.  

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlTANFunction extends HttpServlet
   {
       public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
         {
             rp.setContentType("text/html");
             PrintWriter disp = rp.getWriter();
             String driver = "com.mysql.jdbc.Driver";
             String url = "jdbc:mysql://localhost/dbase";
             String uid = "root";
             String psw = "root";
             Connection con=null;
             PreparedStatement ps = null;
             ResultSet rs;
             try
               {
                    Class.forName(driver);
                    con = DriverManager.getConnection(url,uid,psw);
                    ps=con.prepareStatement("Select TAN(1)");
                    rs = ps.executeQuery();
                String title = "Using TAN Function";
                    String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
                disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                    "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
                "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Value</th>\n"+ "</body> </html>");
                    while(rs.next())
                       {
                            String val = rs.getString(1);
                        disp.println("<tr><td align=\"center\">" + val +"</td></tr>" );  
                       }     
               }      
                        catch(Exception e) 
                              {
                                   e.printStackTrace();
                              }
                                   disp.close();
         }
                         public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                  {
                                     doGet(rq,rp);
                                  }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlTANFunction</servlet-name>
   <servlet-class>MySqlTANFunction</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlTANFunction</servlet-name>
   <url-pattern>/MySqlTANFunction</url-pattern>
</servlet-mapping>

MySql SYSDATE Function in Java Servlet

By Dinesh Thakur

This function Will Returns the time at which the function executes.

First i make a table in database named ‘dbase’ with required fields and values in it and within the reference of mySql(Php Admin).Then i import all the required java package from java library. I made a class named ‘MySqlSystemDateFunc’ extends the ‘HttpServlet’. Then i use serviceMethod() which will bring the request from doGet()Method for Output. Then i load all the drivers for database accessing. After then, i declare variables, which are necessary for database conditions as i declare connection (this variable will use to make a link between database and java code or actual code). After then i declare resultset (this variable will use to get the values from desired columns and rows as required from query). The next one will be the preparedStatement (this variable will responsible for the executing query like executeQuery() as (SELECT SYSDATE() AS dt). In the last i used the doGet()Method which will bring the output on the web Browser.

For getting the output in the tabular form, i use ‘HTML’ code and tags that will show output in a manner way on web browser. 

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlSystemDateFunc extends HttpServlet
   {
        public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
          {
              rp.setContentType("text/html");
              PrintWriter disp = rp.getWriter();
              String driver = "com.mysql.jdbc.Driver";
              String url = "jdbc:mysql://localhost/dbase";
              String uid = "root";
              String psw = "root";
              Connection con=null;
              PreparedStatement ps = null;
              ResultSet rs;
              try
                {
                      Class.forName(driver);
                      con = DriverManager.getConnection(url,uid,psw);
                      ps=con.prepareStatement("SELECT SYSDATE() AS dt");
                      rs = ps.executeQuery();
                  String title = "Using System Date Function";
                      String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
                  disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                      "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
                  "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Result</th>\n"+ "</body> </html>");
                      while(rs.next())
                          {
                              String curr = rs.getString(1);
                          disp.println("<tr><td align=\"center\">" + curr +"</td></tr>" );  
                          }     
             }        
                          catch(Exception e) 
                          {
                                e.printStackTrace();
                          }
                                disp.close();
           }
                         public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                 {
                                     doGet(rq,rp);
                                 }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlSystemDateFunc</servlet-name>
   <servlet-class>MySqlSystemDateFunc</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlSystemDateFunc</servlet-name>
   <url-pattern>/MySqlSystemDateFunc</url-pattern>
</servlet-mapping>

MySql SUM Function in Java Servlet

By Dinesh Thakur

This function Will Return the ADD (sum) value of the required field from a table like (salary, age etc…).

We need to make a table named ‘worker’ into a database named ‘dbase’. The required fields must be filling with values. After that, Java packages to be call from java library. Here we need to define a class named ‘MySqlSUMFunction’ extends the ‘HttpServlet’. This program is been responsible for desired output as required statement from user. Here we use the service method() (this method is responsible for calling the doGet() method to getting the request). the variable which are mandatory to use link or present Backend and Frontend will have to be declared like Connection,ResultSet,preparedStatement all these variables does their required functions or job. Like the connection variable will use to make Connection between database and java code. The drivers are also to be load then created an object of Connection interface. After that preparedStatement will use to represent the Query for output like ‘SELECT SUM(salary) AS total FROM worker’. The resultset will be define as executeQuery() to execute the query for desired result. And in the last we used doGet() method for fetching result on a web browser.

Now on the browser to get an output in designer look we just use the ‘HTML’ code tags, which will present the Output in Tabular form for an efficient look.

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlSUMFunction extends HttpServlet
   {
      public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
        {
             rp.setContentType("text/html");
             PrintWriter disp = rp.getWriter();
             String driver = "com.mysql.jdbc.Driver";
             String url = "jdbc:mysql://localhost/dbase";
             String uid = "root";
             String psw = "root";
             Connection con=null;
             PreparedStatement ps = null;
             ResultSet rs;
             try
              {
                  Class.forName(driver);
                  con = DriverManager.getConnection(url,uid,psw);
                  ps=con.prepareStatement("SELECT SUM(salary) AS total FROM worker");
                  rs = ps.executeQuery();
              String title = "Using SUM(Total) Function";
                  String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
             disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                 "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
             "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Total</th>\n"+ "</body> </html>");
                 while(rs.next())
                     {
                           String tl = rs.getString("total");
                       disp.println("<tr><td align=\"center\">" + tl +"</td></tr>" );  
                     }     
               }      
                      catch(Exception e) 
                        {
                          e.printStackTrace();
                        }
                          disp.close();
         }
                       public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                 {
                                     doGet(rq,rp);
                                 }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlSUMFunction</servlet-name>
   <servlet-class>MySqlSUMFunction</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlSUMFunction</servlet-name>
   <url-pattern>/MySqlSUMFunction</url-pattern>
</servlet-mapping>

MySql SUBTIME Function in Java Servlet

By Dinesh Thakur

This Function will Subtracts time.

First i make a table in database named ‘dbase’ with required fields and values which is under the reference of mySql(php myAdmin). Here i import all mandatory java packages from the java library as program needs. Then after, i make a class named ‘MySqlSubTimeFunc’ extends ‘HttpServlet’. And here i use serviceMethod() which will get request from the doGet()Method for getting output on the web browser. After, i load all the required drivers for accessing database. After, then i declare mandatory variables as i declare ‘Connection’ this variable does the job to create a link between database and the actual code. The other one i declare is ‘resultSet’ that will fetch the value from selected column and rows. Now here i declare the ‘preparedStatement’ that will use to execute the selected query like executeQuery() as (SELECT SUBTIME(‘2:00:00.0’) AS hrago).Here i use the doGet()Method for output on a web browser.

I use ‘HTML’ code and some of its tags that will provide the output on the web browser in tabular form.

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlSubTimeFunc extends HttpServlet
   {
       public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
         {
             rp.setContentType("text/html");
             PrintWriter disp = rp.getWriter();
             String driver = "com.mysql.jdbc.Driver";
             String url = "jdbc:mysql://localhost/dbase";
             String uid = "root";
             String psw = "root";
             Connection con=null;
             PreparedStatement ps = null;
             ResultSet rs;
             try
              {
                   Class.forName(driver);
                   con = DriverManager.getConnection(url,uid,psw);
                   ps=con.prepareStatement("SELECT SUBTIME('2:00:00.0') AS hrago");
                   rs = ps.executeQuery();
               String title = "Using Sub Time Function";
                   String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
               disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                   "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
               "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Result</th>\n"+ "</body> </html>");
                   while(rs.next())
                     {
                          String curr = rs.getString(1);
                      disp.println("<tr><td align=\"center\">" + curr +"</td></tr>" );  
                     }     
               }      
                     catch(Exception e) 
                        {
                         e.printStackTrace();
                        }
                         disp.close();
       }
                       public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                 {
                                     doGet(rq,rp);
                                 }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlSubTimeFunc</servlet-name>
   <servlet-class>MySqlSubTimeFunc</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlSubTimeFunc</servlet-name>
   <url-pattern>/MySqlSubTimeFunc</url-pattern>
</servlet-mapping>

MySql SUBSTRING_INDEX Function in Java Servlet

By Dinesh Thakur

This Function will return a substring from a string before the specified number of occurrences of the delimiter.

First i made a database named ‘dbase’ within the reference of mySql(php myAdmin).Then i import all the required java package from java library according to  need of program. Then i made a class named ‘MySqlSUBSTRINGINDEXFunction’, which extends ‘HTTPSERVLET’ completely. Then after i use service()Method that will bring the request from doGet()Method for output on the web browser. Then after, i loaded al the required drivers for database accessing. Here i declare variables for next use of program i declare ‘connection’ that will use to create a link between the database and the java code. Here i use ‘resultSet’ that will use to get the value from the selected columns and the rows. At the last instance of declaring variable i use ‘preparedStatement’ that will use to executing the selected Query like executeQuery as (Select SUBSTRING_INDEX(‘servlet.mysql.org’,’.’,2)). I use doGet()Method for output on web browser.

I use ‘HTML’ code and tags to show output in tabular form on the web browser that will make output in manner Form.

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlSUBSTRINGINDEXFunction extends HttpServlet
   {
       public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
        {
            rp.setContentType("text/html");
            PrintWriter disp = rp.getWriter();
            String driver = "com.mysql.jdbc.Driver";
            String url = "jdbc:mysql://localhost/dbase";
            String uid = "root";
            String psw = "root";
            Connection con=null;
            PreparedStatement ps = null;
            ResultSet rs;
            try
             {
                 Class.forName(driver);
                 con = DriverManager.getConnection(url,uid,psw);
                 ps=con.prepareStatement("Select SUBSTRING_INDEX('servlet.mysql.org','.',2)");
                 rs = ps.executeQuery();
             String title = "Using SUBSTRING_INDEX Function";
                 String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
             disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                 "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
             "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Value Is </th>\n"+ "</body> </html>");
                 while(rs.next())
                    {
                         String val = rs.getString(1);
                     disp.println("<tr><td align=\"center\">" + val +"</td></tr>" );  
                    }     
              }       
                     catch(Exception e) 
                         {
                         e.printStackTrace();
                         }
                         disp.close();
         }
                       public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                  {
                                     doGet(rq,rp);
                                  }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlSUBSTRINGINDEXFunction</servlet-name>
   <servlet-class>MySqlSUBSTRINGINDEXFunction</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlSUBSTRINGINDEXFunction</servlet-name>
   <url-pattern>/MySqlSUBSTRINGINDEXFunction</url-pattern>
</servlet-mapping>

MySql SUBSTRING Function in Java Servlet

By Dinesh Thakur

This Function Will Return the substring as specified. [Read more…] about MySql SUBSTRING Function in Java Servlet

MySql SUBSTR Function in Java Servlet

By Dinesh Thakur

This Function Will Return the substring as specified.

First, i use to make a database named ‘dbase’ within the reference of mySql(php myAdmin). Then i use to import all required java package from java library. Then after calling all the packages, i made a class named ‘MySqlSUBSTRFunction’, which extends ‘HttpServlet’. I use service()Method which will use to getting the request from doGet()Method for output. Then i loaded all the required drivers for database accessing. After loading driver, I declare the variables like i use ‘connection’ variable that will use to create a link between the database and the java code. Then after, i use ‘resultSet’ that will act as to fetching value from the selected column and rows. I use ‘preparedStatement’ that will use to executing the selected query like executeQuery as (Select SUBSTR(‘servletmysql’,5,4)). I use doGet()Method in last interface which will use to get output on the web browser.

I use here some tags of ‘HTML’ that will bring output in a tabular form as required.

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlSUBSTRFunction extends HttpServlet
   {
       public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
         {
              rp.setContentType("text/html");
              PrintWriter disp = rp.getWriter();
              String driver = "com.mysql.jdbc.Driver";
              String url = "jdbc:mysql://localhost/dbase";
              String uid = "root";
              String psw = "root";
              Connection con=null;
              PreparedStatement ps = null;
              ResultSet rs;
              try
               {
                   Class.forName(driver);
                   con = DriverManager.getConnection(url,uid,psw);
                   ps=con.prepareStatement("Select SUBSTR('servletmysql',5,4)");
                   rs = ps.executeQuery();
               String title = "Using SUBSTR Function";
                   String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
               disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                   "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
               "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Value Is </th>\n"+ "</body> </html>");
                  while(rs.next())
                      {
                          String val = rs.getString(1);
                      disp.println("<tr><td align=\"center\">" + val +"</td></tr>" );  
                      }     
            }         
                      catch(Exception e) 
                          {
                           e.printStackTrace();
                          }
                           disp.close();
          }
                           public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                {
                                     doGet(rq,rp);
                                }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlSUBSTRFunction</servlet-name>
   <servlet-class>MySqlSUBSTRFunction</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlSUBSTRFunction</servlet-name>
   <url-pattern>/MySqlSUBSTRFunction</url-pattern>
</servlet-mapping>

MySql STR_TO_DATE Function in Java Servlet

By Dinesh Thakur

This Function will Converts a string to a date.

First, I make a table in database named ‘dbase’ with required fields and values in it and within the reference of mySql(Php Admin).Then i import all the required java package from java library. I made a class named ‘MySqlStringToDateFunc’ extends the ‘HttpServlet’. Then i use serviceMethod() which will bring the request from doGet()Method for Output. Then i load all the drivers for database accessing. After then, i declare variables which are necessary for database conditions like i declare connection(this variable will use to make a link between database and java code or actual code).after then i declare resultset (this variable will use to get the values from desired columns and rows as required from query). The next one will be the preparedStatement (this variable will responsible for the executing query like executeQuery() as (SELECT STR_TO_DATE(‘21,05,2014′,’%y,%m,%d’) AS str). In the last i used the doGet()Method which will bring the output on the web Browser.

I use here ‘Html’ code and tags that will present the output in tabular form on the web browser.

 import java.io.IOException; 
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MySqlStringToDateFunc extends HttpServlet
   {
      public void service(HttpServletRequest rq, HttpServletResponse rp)throws IOException, ServletException
        {
             rp.setContentType("text/html");
             PrintWriter disp = rp.getWriter();
             String driver = "com.mysql.jdbc.Driver";
             String url = "jdbc:mysql://localhost/dbase";
             String uid = "root";
             String psw = "root";
             Connection con=null;
             PreparedStatement ps = null;
             ResultSet rs;
             try
              {
                  Class.forName(driver);
                  con = DriverManager.getConnection(url,uid,psw);
                  ps=con.prepareStatement("SELECT STR_TO_DATE('21,05,2014','%y,%m,%d') AS str");
                  rs = ps.executeQuery();
              String title = "Using String To Date Function";
                  String docType ="<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n";
              disp.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" +
                  "<body bgcolor=\"#f4efef\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<ul>\n" +
              "<table width=\"50%\" border=\"1\" align=\"center\">\n" + "<th>Result</th>\n"+ "</body> </html>");
                  while(rs.next())
                      {
                           String curr = rs.getString(1);
                       disp.println("<tr><td align=\"center\">" + curr +"</td></tr>" );  
                      }      
             }        
                       catch(Exception e) 
                        {
                            e.printStackTrace();
                        }
                            disp.close();
         }
                       public void doPost(HttpServletRequest rq,HttpServletResponse rp)throws IOException,ServletException
                                 {
                                     doGet(rq,rp);
                                 }
   }
WEB.xml
 
<servlet>
   <servlet-name>MySqlStringToDateFunc</servlet-name>
   <servlet-class>MySqlStringToDateFunc</servlet-class>
</servlet>
<!-- servlet mapping -->
<servlet-mapping>
   <servlet-name>MySqlStringToDateFunc</servlet-name>
   <url-pattern>/MySqlStringToDateFunc</url-pattern>
</servlet-mapping>
Next Page »

Primary Sidebar

Servlet Tutorials

Servlet Tutorials

  • Servlet - Home
  • Servlet - Types
  • Servlet - Advantages
  • Servlet - Container
  • Servlet - API
  • Servlet - Chaining
  • Servlet - Life Cycle
  • Servlet - Developement Way
  • Servlet - Servlet Vs CGI
  • Servlet - Server Side
  • Servlet - HttpServletRequest
  • Servlet - Cookies Advantages
  • Servlet - JDBC Architecture
  • Servlet - HttpServlet
  • Servlet - HttpServletResponse
  • Servlet - Web Technology
  • Servlet - Applet Communication
  • Servlet - Html Communication
  • Servlet - HTTP POST Request
  • Servlet - HTTP GET Request

Other Links

  • Servlet - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW