ad.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String name = txtnm.getText();
String cnm = Integer.toString(id)+name;
try {
System.out.print(cnm);
st = con.createStatement(); // st is an object of Statement class
int result = st.executeUpdate("alter table emp_att add ("+cnm+" varchar(30))"); //how to pass coloumn name in sql query
if(result !=0)
{
JOptionPane.showMessageDialog(null, "Table Altered");
}
else
{
JOptionPane.showMessageDialog(null, "Something Went Wrong..");
}
}
catch (Exception e)
{
System.out.println("Error : " + e);
}
}
});
在上面的代码中我尝试在按钮单击时添加列,但发生SQLException并给出eroor作为ORA-00904 ::无效标识符如何解决此问题
答案 0 :(得分:1)
ORA-00904
告诉您列的名称无效。这是规则:
由于您的列名称以数字而非字母开头,您会收到此错误