本文介绍了我的java程序正在运行编译但没有显示任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
package myproj;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import myproj.util.DBUtil;
/**
*
* @author PEARL
*/
public class DATAENTRY extends javax.swing.JFrame {
/**
* Creates new form DATAENTRY
*/
public DATAENTRY() {
try {
initComponents();
DBUtil util = new DBUtil();
Connection con = util.getConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from bk_det inner join bk_rep on bk_det.rm_id = bk_rep.rm_id inner join bk_sec on bk_rep.rm_id = bk_sec.rm_id inner join mut_det on bk_sec.rm_id = mut_det.rm_id inner join rm_det on mut_det.rm_id = rm_det.rm_id inner join soil_det on rm_det.rm_id = soil_det.rm_id");
ResultSetMetaData rsmetadata = rs.getMetaData();
int columns = rsmetadata.getColumnCount();
DefaultTableModel dtm = new DefaultTableModel();
Vector columns_name = new Vector();
Vector data_rows = new Vector();
for(int i=1; i< columns; i++){
columns_name.addElement(rsmetadata.getColumnName(i));
}
dtm.setColumnIdentifiers(columns_name);
while(rs.next()){
data_rows = new Vector();
for(int j=1; j< columns; j++){
data_rows.addElement(rs.getString(j));
}
dtm.addRow(data_rows);
}
MyTable.setModel(dtm);
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, ex.getMessage());
Logger.getLogger(Demo.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static void main(String arg[]){
}
}
我想将我的sql数据库中的记录显示到netbeans gui中的jtable但是能够显示编译并成功运行Windows窗体但它没有显示受尊重的表格请帮助
i want to display the records from my sql database to my jtable in netbeans gui but am able to display the compile and running the windows form successfully but it doesnot display the respected form please help
推荐答案
这是因为你需要打电话主课程中 DATAENTRY()
This is because you need to call DATAENTRY()
in the main class
这篇关于我的java程序正在运行编译但没有显示任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!