public class Time extends javax.swing.JFrame {
/** Creates new form Time */
public Time() {
initComponents();
generate();
}
public void generate()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:timetable","sa","nish1990()");
String str="select c_name from course where sem_id=1";
Statement str1=con.createStatement();
ResultSet res1=str1.executeQuery(str);
// THIS THE RS PLACE
while(res1.next())
{
String s=res1.getString(1);
JOptionPane.showMessageDialog(this,s);
}
}
catch(SQLException e)
{
System.out.println("SQL Exception :: "+e.toString());
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Time().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextField jTextField6;
private javax.swing.JTextField tf1;
private javax.swing.JTextField tf2;
// End of variables declaration
}
СМОТРИТЕ В МОЮ БАЗУ ДАННЫХ СОДЕРЖИТ ЭТУ ИНФОРМАЦИЮ:
C_NAME
С
Кобол
МАТЕМАТИКА
его можно получить все данные ... я не знаю, как разбить и отобразить в текстовом поле ..
rs.getString (1) содержит C Cobol n Math ...
так как вы берете только C n отображать его
каждый элемент n отображать