
Sir,I kept my some data in backend using ms-access. for Example my data is like this vijayawada is good city.india is my country.i am raja.
when i retrieve this data from backend and keep it in a String .i want to add this String in JLabel like this JLabel o=new JLabel(st); My question is want to display the above data in this format
vijayawada is good city. india is my country. i am raja.

Hi Friend,
Hope that the given code will be helpful for you.
import java.sql.*;
import javax.swing.*;
class RetrieveData{
public static void main(String[] args){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:student");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from data where id=1");
String str="";
while(rs.next()){
str=rs.getString("message");
}
JFrame f=new JFrame();
f.setLayout(null);
JLabel l=new JLabel(str);
l.setBounds(10,10,300,20);
f.add(l);
f.setVisible(true);
f.setSize(350,100);
}
catch(Exception e){
}
}
}
Thanks
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.