为什么在try处提示illegal start of type,怎么回事? 这里不用try怎么捕获读取数据库的异常呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 像下面这么写显示是true或false,而不是钩package fee7;import java.awt.*;import javax.swing.JFrame;import com.borland.jbcl.layout.*;import java.awt.event.*;import opendb.opendb;import java.sql.*;import javax.swing.*;public class importData extends JFrame { private XYLayout xYLayout1 = new XYLayout(); private Button button2 = new Button(); private Button button1 = new Button(); private Button button3 = new Button(); private JTable jTable1 = new JTable(); private JScrollPane jScrollPane1 = new JScrollPane(jTable1); public importData(final JFrame mainFrame) { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } mainFrame.setEnabled(false); button2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { button2_actionPerformed(e); } void button2_actionPerformed(ActionEvent e) { mainFrame.setEnabled(true); importData.this.dispose(); }}); } private void jbInit() throws Exception { this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); this.setResizable(false); this.setTitle("导入数据"); this.setSize(new Dimension(600, 400)); java.awt.Dimension d = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation((d.width - this.getSize().width) / 2, (d.height - this.getSize().height) / 2 ); // the above is sure for middle showing button1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { button1_actionPerformed(e); } }); button1.setLabel("导入"); button1.setFont(new java.awt.Font("Dialog", 0, 14)); button2.setFont(new java.awt.Font("Dialog", 0, 14)); button2.setLabel("取消"); this.getContentPane().setLayout(xYLayout1); button3.setFont(new java.awt.Font("Dialog", 0, 14)); button3.setLabel("显示未导数据"); button3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { button3_actionPerformed(e); } }); this.getContentPane().add(button1, new XYConstraints(185, 315, 76, 32)); this.getContentPane().add(button2, new XYConstraints(338, 316, 76, 32)); this.getContentPane().add(button3, new XYConstraints(242, 28, 122, 32)); } //***********page变量********** opendb imData=new opendb(); Object[][] data=new Object[20][8]; //**************************** void button1_actionPerformed(ActionEvent e) { } void button3_actionPerformed(ActionEvent e) { String sqlblock="select * from block where blockname!='null'"; try { ResultSet rs; rs=imData.dbstatement.executeQuery(sqlblock); }catch(Exception error){error.printStackTrace();} //************显示表格************** try { String block="select blockname,buildingNumber,buildingNumberReal,wholeArea,wholeAreaReal,wholePrice,wholePriceReal from block where blockname!='null'"; ResultSet rs1=imData.dbstatement.executeQuery(block); String[] columnNames={"小区名称","应收楼数","实收楼数","应收总面积","实收总面积","应收总金额","实收总金额","状态"}; rs1.last(); int a=rs1.getRow(); data = new Object[a][8]; rs1.beforeFirst(); int i=0; while(rs1.next()) { for(int col=1; col<=7; col++)//取列值 data[i][col-1] = rs1.getString(col); data[i][7]=new Boolean(false); i++; data[0][7].getClass(); } jTable1=new JTable(data,columnNames); jTable1.setEnabled(false); jTable1.getTableHeader( ).setReorderingAllowed( false ); this.getContentPane().add(jScrollPane1, new XYConstraints(47, 88, 500, 200)); jScrollPane1.getViewport().add(jTable1, null); this.show(); rs1.close(); }catch(Exception ar){ar.printStackTrace();} //******************************* } public Object getValueAt(int row, int col) { return data[row][col]; } public Class getColumnClass(int c) { return getValueAt(0, c).getClass(); }} 工作空间是干什么的 help help ! java 读取xp 系统下串口,不能获取到串口 java小问题!!! 代码优化,金碟面试题?? JAVA 连接oracle数据库,有什么驱动连接比较快呢 求助 请问一个java网络编程的问题 split 的问题(急!拜托!) 如何使java 的图形应用程序上的最大化按钮失效? 使用eclipse和sysdeo进行开发时,为什么经常会出现8080端口被占用的情况? java中的汉字显示问题? ***java.io中的管道可以用来做什么?有什么好处?
import javax.swing.JFrame;
import com.borland.jbcl.layout.*;
import java.awt.event.*;
import opendb.opendb;
import java.sql.*;
import javax.swing.*;public class importData extends JFrame {
private XYLayout xYLayout1 = new XYLayout();
private Button button2 = new Button();
private Button button1 = new Button();
private Button button3 = new Button();
private JTable jTable1 = new JTable();
private JScrollPane jScrollPane1 = new JScrollPane(jTable1); public importData(final JFrame mainFrame) {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
} mainFrame.setEnabled(false);
button2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button2_actionPerformed(e);
}
void button2_actionPerformed(ActionEvent e) {
mainFrame.setEnabled(true);
importData.this.dispose();
}});
}
private void jbInit() throws Exception {
this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.setResizable(false);
this.setTitle("导入数据");
this.setSize(new Dimension(600, 400));
java.awt.Dimension d = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation((d.width - this.getSize().width) / 2,
(d.height - this.getSize().height) / 2 );
// the above is sure for middle showing
button1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button1_actionPerformed(e);
}
});
button1.setLabel("导入");
button1.setFont(new java.awt.Font("Dialog", 0, 14));
button2.setFont(new java.awt.Font("Dialog", 0, 14));
button2.setLabel("取消"); this.getContentPane().setLayout(xYLayout1);
button3.setFont(new java.awt.Font("Dialog", 0, 14));
button3.setLabel("显示未导数据");
button3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button3_actionPerformed(e);
}
});
this.getContentPane().add(button1, new XYConstraints(185, 315, 76, 32));
this.getContentPane().add(button2, new XYConstraints(338, 316, 76, 32));
this.getContentPane().add(button3, new XYConstraints(242, 28, 122, 32));
}
//***********page变量**********
opendb imData=new opendb();
Object[][] data=new Object[20][8];
//****************************
void button1_actionPerformed(ActionEvent e) { }
void button3_actionPerformed(ActionEvent e) {
String sqlblock="select * from block where blockname!='null'";
try
{
ResultSet rs;
rs=imData.dbstatement.executeQuery(sqlblock);
}catch(Exception error){error.printStackTrace();} //************显示表格**************
try
{
String block="select blockname,buildingNumber,buildingNumberReal,wholeArea,wholeAreaReal,wholePrice,wholePriceReal from block where blockname!='null'";
ResultSet rs1=imData.dbstatement.executeQuery(block);
String[] columnNames={"小区名称","应收楼数","实收楼数","应收总面积","实收总面积","应收总金额","实收总金额","状态"};
rs1.last();
int a=rs1.getRow();
data = new Object[a][8];
rs1.beforeFirst();
int i=0;
while(rs1.next())
{
for(int col=1; col<=7; col++)//取列值
data[i][col-1] = rs1.getString(col);
data[i][7]=new Boolean(false);
i++;
data[0][7].getClass();
}
jTable1=new JTable(data,columnNames);
jTable1.setEnabled(false);
jTable1.getTableHeader( ).setReorderingAllowed( false );
this.getContentPane().add(jScrollPane1, new XYConstraints(47, 88, 500, 200));
jScrollPane1.getViewport().add(jTable1, null);
this.show();
rs1.close();
}catch(Exception ar){ar.printStackTrace();}
//*******************************
}
public Object getValueAt(int row, int col) {
return data[row][col];
} public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
}}