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

I want to display database records as per clock timing.

Ads

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 Tutorials/Questions & Answers:
Advertisements

Ads

Advertisement