Home Answers Viewqa JSP-Servlet How to display mysql database records as per clock timing?

 
 


rakesh dilip patil
How to display mysql database records as per clock timing?
1 Answer(s)      a year and a month ago
Posted in : JSP-Servlet

I want to display database records as per clock timing.

View Answers

April 28, 2012 at 3:28 PM


import java.sql.*;

class RetrieveData 
{
    public static void main(String[] args) throws Exception
    {
                Class.forName("com.mysql.jdbc.Driver").newInstance();
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root" );
        Statement st=conn.createStatement();
        ResultSet rs=st.executeQuery("select * from data");

        while(rs.next()){
            String name=rs.getString("name");
            String address=rs.getString("address");
            String contact=rs.getString("contactNo");
            String email=rs.getString("email");

            System.out.println(name+" \t "+address+" \t "+contact+" \t "+email);
            Thread.sleep(2000);
        }
    }
}









Related Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.