
I want to display database records as per clock timing.

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);
}
}
}
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.