
if we create the query table means how we retrive the query content from database,

import java.sql.*;
class Retrieve{
public static void main(String[] args){
try{
int id=2;
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from employee where id="+id+"");
if(rs.next()){
System.out.println("Name: "+rs.getString("name"));
System.out.println("Address: "+rs.getString("address"));
System.out.println("Contact No: "+rs.getInt("contactNo"));
System.out.println("Email: "+rs.getString("email"));
}
}
catch(Exception e){
System.out.println(e);
}
}
}
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.