class InsertRecord extends JDialog implements ActionListener{ //负责插入记录的类
JLabel hintLabel;
Object[] name={"学号","姓名","性别","年龄"};
Object[][] a=new Object[1][4];
JTable table;
JButton enterInsert;
Connection con;
Statement sql;
ResultSet rs;
String num;
InsertRecord(String s){
setTitle(s);
hintLabel=new JLabel("输入新记录:");
table=new JTable(a,name);
enterInsert=new JButton("插入新记录");
setLayout(null);
Box baseBox=Box.createHorizontalBox();
baseBox.add(hintLabel);
baseBox.add(new JScrollPane(table));
baseBox.add(enterInsert);
add(baseBox);
baseBox.setBounds(10,40,600,38);
enterInsert.addActionListener(this);
setBounds(120,160,700,200);
}
public void actionPerformed(ActionEvent e){
/* try{ con=DriverManager.getConnection("jdbc:odbc:jec","system","jec");
sql=con.createStatement();
int k=sql.executeUpdate
("INSERT INTO s VALUES('a[0][0]','a[0][1]','a[0][2]','a[0][3]')");
if(k==1)
JOptionPane.showMessageDialog
(this,"插入记录成功","成功",JOptionPane.PLAIN_MESSAGE);
table=new JTable(a,name);
con.close();
}
catch(SQLException ee){
JOptionPane.showMessageDialog
(this,"插入记录失败"+ee,"失败",JOptionPane.ERROR_MESSAGE);
} */
System.out.println(a[0][0]+""+a[0][1]+""+a[0][2]+""+a[0][3]);
}
}
为什么a[0][3]显示为null 其他的都显示正常 谁能帮我解决一下
JLabel hintLabel;
Object[] name={"学号","姓名","性别","年龄"};
Object[][] a=new Object[1][4];
JTable table;
JButton enterInsert;
Connection con;
Statement sql;
ResultSet rs;
String num;
InsertRecord(String s){
setTitle(s);
hintLabel=new JLabel("输入新记录:");
table=new JTable(a,name);
enterInsert=new JButton("插入新记录");
setLayout(null);
Box baseBox=Box.createHorizontalBox();
baseBox.add(hintLabel);
baseBox.add(new JScrollPane(table));
baseBox.add(enterInsert);
add(baseBox);
baseBox.setBounds(10,40,600,38);
enterInsert.addActionListener(this);
setBounds(120,160,700,200);
}
public void actionPerformed(ActionEvent e){
/* try{ con=DriverManager.getConnection("jdbc:odbc:jec","system","jec");
sql=con.createStatement();
int k=sql.executeUpdate
("INSERT INTO s VALUES('a[0][0]','a[0][1]','a[0][2]','a[0][3]')");
if(k==1)
JOptionPane.showMessageDialog
(this,"插入记录成功","成功",JOptionPane.PLAIN_MESSAGE);
table=new JTable(a,name);
con.close();
}
catch(SQLException ee){
JOptionPane.showMessageDialog
(this,"插入记录失败"+ee,"失败",JOptionPane.ERROR_MESSAGE);
} */
System.out.println(a[0][0]+""+a[0][1]+""+a[0][2]+""+a[0][3]);
}
}
为什么a[0][3]显示为null 其他的都显示正常 谁能帮我解决一下
解决方案 »
- jsp 客户端脚本的方法选择 getElementById 和getElementByname
- java内存泄漏
- java中//!注释怎么理解
- 怎么快速读取这钟字符串一次两个"str1/str2/str3.."
- 给hibernate配置文件加密 解密的方案(Spring)222222222
- 刚开始学java,有个特别简单的问题
- 如何使applet能够访问本地资源
- JCreator LE 3.0的中文支持问题~~~~~~~~~~~~~~~~~
- 请问如何能连上sql数据库
- applet的运行--新手的郁闷,快来帮忙!!!!在线等待!!!!!!!!!!
- 手机号码中间几位的隐藏
- 奇怪的重载overloading?我该调用哪个???
只有3个 你再加一个就可以了吧 数组的下标是从0开始的